Closed Bug 1682 Opened 23 years ago Closed 22 years ago

duplicate onLoad invocations

Categories

(Core :: DOM: Core & HTML, defect, P2)

x86
Windows NT
defect

Tracking

()

VERIFIED FIXED

People

(Reporter: kipp, Assigned: joki)

Details

(Whiteboard: 7/9 Awaiting response from kipp)

The following test for some reason, when *initially* loaded by the viewer,
executes the "runAlltests" function *twice*. Subsequent loads (hitting return in
the location box) do not do it.

Here is the HTML:
--CUT--
<HTML>
 <HEAD>
  <STYLE type="text/css">
  </STYLE>
  <SCRIPT SRC=foo.js>
  </SCRIPT>
 </HEAD>
 <BODY ONLOAD="runAllTests();">
 </BODY>
</HTML>
--CUT--

Here is the foo.js file:

--CUT--
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/

// Logging functions

var logWindow;

function log(msg)
{
  if (false) {
  if (null == logWindow) {
    logWindow = window.open("logindex.html",'tCw','width=500,height=200');
  }
  var doc = logWindow.document;
  var text = doc.createTextNode(msg);
//  var br = createBreak(null);
  doc.appendChild(text);
//  doc.appendChild(br);
  } else {
    dump(msg + "\n");
  }
}

//----------------------------------------

var doc = document;
var nextID = 0;
var nextTextID = 0;

function getNode()
{
  var id = document.getElementById("IDChoice");
  if (null != id) {
    var value = id.value;
    if ((null != value) && (value.length > 0)) {
      var node = doc.getElementById(value);
      if (null != node) {
        return node;
      }
    }
  }
  return null;
}

function newID()
{
  return "_genid_" + nextID++;
}

function getID()
{
  var id = document.getElementById("IDChoice");
  if (null != id) {
    var value = id.value;
    if ((null != value) && (value.length > 0)) {
      var node = doc.getElementById(value);
      if (null != node) {
        return newID();
      }
      return value;
    }
  }
  return newID();
}

//----------------------------------------

function createText(yak)
{
  var s;
  if (null != yak) {
    s = yak;
  }
  else {
    s = "This text is in autogenerated [" + nextTextID++ + "] ";
  }
  var it = doc.createTextNode(s);
  return it;
}

function createBreak(clear)
{
  var it = doc.createElement("BR");
  if (null == it) {
    log("Bad DOM: can't create BR");
  }
  else {
    var id = getID();
    it.setDOMAttribute("ID", id);
    if (null != clear) {
      it.setDOMAttribute("CLEAR", clear);
    }
  }
  return it;
}

function createImage(src, align, w, h)
{
  var it = doc.createElement("IMG");
  if (null == it) {
    log("Bad DOM: can't create IMG");
  }
  else {
    var id = getID();
    it.setDOMAttribute("ID", id);
    it.setDOMAttribute("SRC", src);
    it.setDOMAttribute("BORDER", "1");
    if (null != align) {
      it.setDOMAttribute("ALIGN", align);
    }
    if (null != w) {
      it.setDOMAttribute("WIDTH", w);
    }
    if (null != h) {
      it.setDOMAttribute("HEIGHT", h);
    }
  }
  return it;
}

function createParagraph()
{
  var it = doc.createElement("P");
  var id = getID();
  it.setDOMAttribute("ID", id);
  var text = doc.createTextNode("This text is in autogenerated [" +
                                nextTextID++ + "] (ID=" + id + ")");
  it.appendChild(text);
  return it;
}

//----------------------------------------

function removeParagraph()
{
  var node = getNode();
  if (null != node) {
    var parent = node.parentNode;
    if (null != parent) {
      parent.removeChild(node);
    }
  }
}
//----------------------------------------

var bww =
"This is some text. It will be word wrapped because our container will " +
"word wrap us. It will also be baseline aligned because our container " +
"will do that too. " +
"This is some text. It will be word wrapped because our container will " +
"word wrap us. It will also be baseline aligned because our container " +
"will do that too.";

var bww0 =
"This is some text.";

function testAppend()
{
  var parent = document.body;
  var n;

  if (false) {
  n = createText(null);                         parent.appendChild(n);
  n = createBreak(null);                        parent.appendChild(n);
  n = createText("foo");                        parent.appendChild(n);
  n = createParagraph();                        parent.appendChild(n);

  n = createImage("raptor.jpg", null, "50", null);
  parent.appendChild(n);
  }
  n = createText(bww0);                         parent.appendChild(n);
  n = createBreak("all");                       parent.appendChild(n);

  n = createImage("raptor.jpg", "left");        parent.appendChild(n);
  if (false) {
  n = createText(null);                         parent.appendChild(n);
  n = createBreak(null);                        parent.appendChild(n);
  n = createText("foo");                        parent.appendChild(n);
  n = createParagraph();                        parent.appendChild(n);

  n = createImage("raptor.jpg", null, "50", null);
  parent.appendChild(n);

  n = createText(bww);                          parent.appendChild(n);
  n = createBreak("all");                       parent.appendChild(n);
}
}

//----------------------------------------

// Testing TODO:

// 1. insert floater
// 2. remove floater
// 3. change floater size

// 1. insert break
// 2. remove break
// 3. change break clear style

// 1. insert text into text
// 2. insert text after other
// 3. insert text before other

// 1. insert block
// 2. remove block

// 1. insert span
// 2. remove span
// 3. repeat all tests in a span instead of in a block

function runAllTests()
{
  log("Here we go...");
  testAppend();
  log("Task Complete <beep>.");
}
--CUT--
Assignee: vidur → joki
Setting all current Open/Normal to M4.
per leger, assigning QA contacts to all open bugs without QA contacts according
to list at http://bugzilla.mozilla.org/describecomponents.cgi?product=Browser
QA Contact: 4015 → 3847
QA contact re-assigned according to the product areas we're currently working
on.
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
This seems to work now.  I would guess it got picked up with some other script
loading issues.

Note for testing: The test is kind of old.  To make it work you have to replace
all of the setDOMAttribute calls with setAttribute.
Kipp, I tried running this in an old build and in the new one (with the change
to setDomAttribute) and don't see a difference.  Possibly I'm not doing it
right.  Is it fixed for you?
Whiteboard: Awaiting response from kipp
Whiteboard: Awaiting response from kipp → 6/17 Awaiting response from kipp
Whiteboard: 6/17 Awaiting response from kipp → 7/9 Awaiting response from kipp
Status: RESOLVED → VERIFIED
haven't gotten a response from reporter.  Assuming this is fixed due to lack of
further comments to this report.  Marking verified.
I haven't tried this test in aeons...If it works for you, then lets leave it
verified. Thanks...
RCS file: /cvsroot/mozilla/testing/mochitest/tests/test_bug1682.html,v
done
Checking in test_bug1682.html;
/cvsroot/mozilla/testing/mochitest/tests/test_bug1682.html,v  <--  test_bug1682.html
initial revision: 1.1
done
Flags: in-testsuite+
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.