Skip to content

Commit

Permalink
Bug 368994. move mochitests near the code they test. round 7. r=bzbarsky
Browse files Browse the repository at this point in the history
  • Loading branch information
sayrer committed Apr 16, 2007
1 parent 79a44c3 commit b80cfd9
Show file tree
Hide file tree
Showing 28 changed files with 1,047 additions and 13 deletions.
1 change: 1 addition & 0 deletions content/base/test/Makefile.in
Expand Up @@ -52,6 +52,7 @@ _TEST_FILES = test_bug5141.html \
test_bug276037-1.html \
test_bug276037-2.xhtml \
test_bug308484.html \
test_bug311681.xml \
test_bug337631.html \
test_bug338541.xhtml \
test_bug338679.html \
Expand Down
106 changes: 106 additions & 0 deletions content/base/test/test_bug311681.xml
@@ -0,0 +1,106 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=311681
-->
<head>
<title>Test for Bug 311681</title>
<script type="text/javascript" src="/MochiKit/packed.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=311681">Mozilla Bug 311681</a>
<script class="testbody" type="text/javascript">
<![CDATA[
// Setup script
SimpleTest.waitForExplicitFinish();
// Make sure to trigger the hashtable case by asking for enough elements
// by ID.
for (var i = 0; i < 256; ++i) {
var x = document.getElementById(i);
}
// save off the document.getElementById function, since getting it as a
// property off the document it causes a content flush.
var fun = document.getElementById;
// Slot for our initial element with id "content"
var testNode;
function getCont() {
return fun.call(document, "content");
}
function testClone() {
// Test to make sure that if we have multiple nodes with the same ID in
// a document we don't forget about one of them when the other is
// removed.
var newParent = $("display");
var node = testNode.cloneNode(true);
isnot(node, testNode, "Clone should be a different node");
newParent.appendChild(node);
// Check what getElementById returns, no flushing
todo(getCont() == testNode, "Should be getting orig node pre-flush 1");
is(getCont(), node, "XML does it differently, for now");
// Trigger a layout flush, just in case.
var itemHeight = newParent.offsetHeight/10;
// Check what getElementById returns now.
todo(getCont() == testNode, "Should be getting orig node post-flush 1");
is(getCont(), node, "XML does it differently, for now");
clear(newParent);
// Check what getElementById returns, no flushing
is(getCont(), testNode, "Should be getting orig node pre-flush 2");
// Trigger a layout flush, just in case.
var itemHeight = newParent.offsetHeight/10;
// Check what getElementById returns now.
is(getCont(), testNode, "Should be getting orig node post-flush 2");
node = testNode.cloneNode(true);
newParent.appendChild(node);
testNode.parentNode.removeChild(testNode);
// Check what getElementById returns, no flushing
is(getCont(), node, "Should be getting clone pre-flush");
// Trigger a layout flush, just in case.
var itemHeight = newParent.offsetHeight/10;
// Check what getElementById returns now.
is(getCont(), node, "Should be getting clone post-flush");
}
function clear(node) {
while (node.hasChildNodes()) {
node.removeChild(node.firstChild);
}
}
addLoadEvent(testClone);
addLoadEvent(SimpleTest.finish);
]]>
</script>
<p id="display"></p>
<div id="content" style="display: none">
<script class="testbody" type="text/javascript">
<![CDATA[
testNode = fun.call(document, "content");
// Needs incremental XML parser
isnot(testNode, null, "Should have node here");
]]>
</script>
</div>
<pre id="test">
</pre>
</body>
</html>

2 changes: 2 additions & 0 deletions content/html/document/test/Makefile.in
Expand Up @@ -47,6 +47,8 @@ include $(topsrcdir)/config/rules.mk
_TEST_FILES = test_bug1682.html \
test_bug1823.html \
test_bug172261.html \
test_bug311681.html \
test_bug311681.xhtml \
test_bug332848.xhtml \
test_bug359657.html \
$(NULL)
Expand Down
100 changes: 100 additions & 0 deletions content/html/document/test/test_bug311681.html
@@ -0,0 +1,100 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=311681
-->
<head>
<title>Test for Bug 311681</title>
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=311681">Mozilla Bug 311681</a>
<script class="testbody" type="text/javascript">
// Setup script
SimpleTest.waitForExplicitFinish();

// Make sure to trigger the hashtable case by asking for enough elements
// by ID.
for (var i = 0; i < 256; ++i) {
var x = document.getElementById(i);
}

// save off the document.getElementById function, since getting it as a
// property off the document it causes a content flush.
var fun = document.getElementById;

// Slot for our initial element with id "content"
var testNode;

function getCont() {
return fun.call(document, "content");
}

function testClone() {
// Test to make sure that if we have multiple nodes with the same ID in
// a document we don't forget about one of them when the other is
// removed.
var newParent = $("display");
var node = testNode.cloneNode(true);
isnot(node, testNode, "Clone should be a different node");

newParent.appendChild(node);

// Check what getElementById returns, no flushing
is(getCont(), testNode, "Should be getting orig node pre-flush 1");

// Trigger a layout flush, just in case.
var itemHeight = newParent.offsetHeight/10;

// Check what getElementById returns now.
is(getCont(), testNode, "Should be getting orig node post-flush 1");

clear(newParent);

// Check what getElementById returns, no flushing
is(getCont(), testNode, "Should be getting orig node pre-flush 2");

// Trigger a layout flush, just in case.
var itemHeight = newParent.offsetHeight/10;

// Check what getElementById returns now.
is(getCont(), testNode, "Should be getting orig node post-flush 2");

node = testNode.cloneNode(true);
newParent.appendChild(node);
testNode.parentNode.removeChild(testNode);

// Check what getElementById returns, no flushing
is(getCont(), node, "Should be getting clone pre-flush");

// Trigger a layout flush, just in case.
var itemHeight = newParent.offsetHeight/10;

// Check what getElementById returns now.
is(getCont(), node, "Should be getting clone post-flush");

}

function clear(node) {
while (node.hasChildNodes()) {
node.removeChild(node.firstChild);
}
}

addLoadEvent(testClone);
addLoadEvent(SimpleTest.finish);
</script>
<p id="display"></p>
<div id="content" style="display: none">
<script class="testbody" type="text/javascript">
testNode = fun.call(document, "content");
isnot(testNode, null, "Should have node here");
</script>
</div>
<pre id="test">
</pre>
</body>
</html>

105 changes: 105 additions & 0 deletions content/html/document/test/test_bug311681.xhtml
@@ -0,0 +1,105 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=311681
-->
<head>
<title>Test for Bug 311681</title>
<script type="text/javascript" src="/MochiKit/packed.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=311681">Mozilla Bug 311681</a>
<script class="testbody" type="text/javascript">
<![CDATA[
// Setup script
SimpleTest.waitForExplicitFinish();

// Make sure to trigger the hashtable case by asking for enough elements
// by ID.
for (var i = 0; i < 256; ++i) {
var x = document.getElementById(i);
}

// save off the document.getElementById function, since getting it as a
// property off the document it causes a content flush.
var fun = document.getElementById;

// Slot for our initial element with id "content"
var testNode;

function getCont() {
return fun.call(document, "content");
}

function testClone() {
// Test to make sure that if we have multiple nodes with the same ID in
// a document we don't forget about one of them when the other is
// removed.
var newParent = $("display");
var node = testNode.cloneNode(true);
isnot(node, testNode, "Clone should be a different node");

newParent.appendChild(node);

// Check what getElementById returns, no flushing
is(getCont(), testNode, "Should be getting orig node pre-flush 1");

// Trigger a layout flush, just in case.
var itemHeight = newParent.offsetHeight/10;

// Check what getElementById returns now.
is(getCont(), testNode, "Should be getting orig node post-flush 1");

clear(newParent);

// Check what getElementById returns, no flushing
is(getCont(), testNode, "Should be getting orig node pre-flush 2");

// Trigger a layout flush, just in case.
var itemHeight = newParent.offsetHeight/10;

// Check what getElementById returns now.
is(getCont(), testNode, "Should be getting orig node post-flush 2");

node = testNode.cloneNode(true);
newParent.appendChild(node);
testNode.parentNode.removeChild(testNode);

// Check what getElementById returns, no flushing
is(getCont(), node, "Should be getting clone pre-flush");

// Trigger a layout flush, just in case.
var itemHeight = newParent.offsetHeight/10;

// Check what getElementById returns now.
is(getCont(), node, "Should be getting clone post-flush");

}

function clear(node) {
while (node.hasChildNodes()) {
node.removeChild(node.firstChild);
}
}

// Actually run the test once the XML parser works incrementally
// addLoadEvent(testClone);
addLoadEvent(SimpleTest.finish);
]]>
</script>
<p id="display"></p>
<div id="content" style="display: none">
<script class="testbody" type="text/javascript">
<![CDATA[
testNode = fun.call(document, "content");
// Needs incremental XML parser
todo(testNode != null, "Should have node here");
]]>
</script>
</div>
<pre id="test">
</pre>
</body>
</html>

4 changes: 4 additions & 0 deletions content/xul/document/Makefile.in
Expand Up @@ -45,5 +45,9 @@ include $(DEPTH)/config/autoconf.mk
MODULE = xuldoc
DIRS = public src

ifdef MOZ_MOCHITEST
DIRS += test
endif

include $(topsrcdir)/config/rules.mk

52 changes: 52 additions & 0 deletions content/xul/document/test/Makefile.in
@@ -0,0 +1,52 @@
#
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is
# Mozilla Foundation.
# Portions created by the Initial Developer are Copyright (C) 2007
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either of the GNU General Public License Version 2 or later (the "GPL"),
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****

DEPTH = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
relativesrcdir = content/xul/document/test

include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk

_TEST_FILES = \
test_bug311681.xul \
$(NULL)

libs:: $(_TEST_FILES)
$(INSTALL) $^ $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)

0 comments on commit b80cfd9

Please sign in to comment.