summaryrefslogtreecommitdiffstats
path: root/dom/base/test
diff options
context:
space:
mode:
Diffstat (limited to 'dom/base/test')
-rw-r--r--dom/base/test/chrome/registerElement_ep.js4
-rw-r--r--dom/base/test/chrome/test_registerElement_content.xul23
-rw-r--r--dom/base/test/chrome/test_registerElement_ep.xul4
-rw-r--r--dom/base/test/mochitest.ini4
-rw-r--r--dom/base/test/mutationobserver_dialog.html62
-rw-r--r--dom/base/test/test_dialogArguments.html31
-rw-r--r--dom/base/test/test_mutationobservers.html55
7 files changed, 46 insertions, 137 deletions
diff --git a/dom/base/test/chrome/registerElement_ep.js b/dom/base/test/chrome/registerElement_ep.js
index de32ba51c..9189593c0 100644
--- a/dom/base/test/chrome/registerElement_ep.js
+++ b/dom/base/test/chrome/registerElement_ep.js
@@ -1,8 +1,8 @@
var proto = Object.create(HTMLElement.prototype);
proto.magicNumber = 42;
-proto.createdCallback = function() {
+proto.connectedCallback = function() {
finishTest(this.magicNumber === 42);
};
document.registerElement("x-foo", { prototype: proto });
-document.createElement("x-foo");
+document.firstChild.appendChild(document.createElement("x-foo"));
diff --git a/dom/base/test/chrome/test_registerElement_content.xul b/dom/base/test/chrome/test_registerElement_content.xul
index 9a918f2d7..bf00ed53d 100644
--- a/dom/base/test/chrome/test_registerElement_content.xul
+++ b/dom/base/test/chrome/test_registerElement_content.xul
@@ -21,19 +21,13 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1130028
<script type="application/javascript"><![CDATA[
/** Test for Bug 1130028 **/
- SimpleTest.waitForExplicitFinish();
+ var connectedCallbackCount = 0;
- var createdCallbackCount = 0;
-
- // Callback should be called once by element created in chrome,
- // and once by element created in content.
- function createdCallbackCalled() {
- createdCallbackCount++;
- ok(true, "Created callback called, should be called twice in test.");
+ // Callback should be called only once by element created in content.
+ function connectedCallbackCalled() {
+ connectedCallbackCount++;
+ is(connectedCallbackCount, 1, "Connected callback called, should be called once in test.");
is(this.magicNumber, 42, "Callback should be able to see the custom prototype.");
- if (createdCallbackCount == 2) {
- SimpleTest.finish();
- }
}
function startTests() {
@@ -45,10 +39,13 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1130028
var proto = Object.create(frame.contentWindow.HTMLElement.prototype);
proto.magicNumber = 42;
- proto.createdCallback = createdCallbackCalled;
+ proto.connectedCallback = connectedCallbackCalled;
+
frame.contentDocument.registerElement("x-bar", { prototype: proto });
+ is(connectedCallbackCount, 1, "Connected callback should be called by element created in content.");
- frame.contentDocument.createElement("x-bar");
+ var element = frame.contentDocument.createElement("x-bar");
+ is(element.magicNumber, 42, "Should be able to see the custom prototype on created element.");
}
]]></script>
diff --git a/dom/base/test/chrome/test_registerElement_ep.xul b/dom/base/test/chrome/test_registerElement_ep.xul
index 6f1745268..b6a160c2e 100644
--- a/dom/base/test/chrome/test_registerElement_ep.xul
+++ b/dom/base/test/chrome/test_registerElement_ep.xul
@@ -26,8 +26,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1130028
SimpleTest.waitForExplicitFinish();
function finishTest(canSeePrototype) {
- ok(true, "createdCallback called when reigsterElement was called with an extended principal.");
- ok(canSeePrototype, "createdCallback should be able to see custom prototype.");
+ ok(true, "connectedCallback called when reigsterElement was called with an extended principal.");
+ ok(canSeePrototype, "connectedCallback should be able to see custom prototype.");
SimpleTest.finish();
}
diff --git a/dom/base/test/mochitest.ini b/dom/base/test/mochitest.ini
index b3b804ce4..3dfd666f8 100644
--- a/dom/base/test/mochitest.ini
+++ b/dom/base/test/mochitest.ini
@@ -196,7 +196,6 @@ support-files =
formReset.html
invalid_accesscontrol.resource
invalid_accesscontrol.resource^headers^
- mutationobserver_dialog.html
orientationcommon.js
script-1_bug597345.sjs
script-2_bug597345.js
@@ -627,9 +626,6 @@ subsuite = clipboard
skip-if = toolkit == 'android' #bug 904183
[test_createHTMLDocument.html]
[test_declare_stylesheet_obsolete.html]
-[test_dialogArguments.html]
-tags = openwindow
-skip-if = toolkit == 'android' || e10s # showmodaldialog
[test_document.all_iteration.html]
[test_document.all_unqualified.html]
[test_document_constructor.html]
diff --git a/dom/base/test/mutationobserver_dialog.html b/dom/base/test/mutationobserver_dialog.html
deleted file mode 100644
index 2cc815309..000000000
--- a/dom/base/test/mutationobserver_dialog.html
+++ /dev/null
@@ -1,62 +0,0 @@
-<html>
- <head>
- <title></title>
- <script>
-
- var div = document.createElement("div");
-
- var M;
- if ("MozMutationObserver" in window) {
- M = window.MozMutationObserver;
- } else if ("WebKitMutationObserver" in window) {
- M = window.WebKitMutationObserver;
- } else {
- M = window.MutationObserver;
- }
-
- var didCall1 = false;
- var didCall2 = false;
- function testMutationObserverInDialog() {
- div.innerHTML = "<span>1</span><span>2</span>";
- m = new M(function(records, observer) {
- opener.is(records[0].type, "childList", "Should have got childList");
- opener.is(records[0].removedNodes.length, 2, "Should have got removedNodes");
- opener.is(records[0].addedNodes.length, 1, "Should have got addedNodes");
- observer.disconnect();
- m = null;
- didCall1 = true;
- });
- m.observe(div, { childList: true });
- div.innerHTML = "<span><span>foo</span></span>";
- }
-
- function testMutationObserverInDialog2() {
- div.innerHTML = "<span>1</span><span>2</span>";
- m = new M(function(records, observer) {
- opener.is(records[0].type, "childList", "Should have got childList");
- opener.is(records[0].removedNodes.length, 2, "Should have got removedNodes");
- opener.is(records[0].addedNodes.length, 1, "Should have got addedNodes");
- observer.disconnect();
- m = null;
- didCall2 = true;
- });
- m.observe(div, { childList: true });
- div.innerHTML = "<span><span>foo</span></span>";
- }
-
- window.addEventListener("load", testMutationObserverInDialog);
- window.addEventListener("load", testMutationObserverInDialog2);
- window.addEventListener("load",
- function() {
- opener.ok(didCall1, "Should have called 1st mutation callback");
- opener.ok(didCall2, "Should have called 2nd mutation callback");
- window.close();
- });
- </script>
- <style>
- </style>
- </head>
- <body>
- <input type="button" onclick="window.close()" value="close">
- </body>
-</html>
diff --git a/dom/base/test/test_dialogArguments.html b/dom/base/test/test_dialogArguments.html
deleted file mode 100644
index 70a091d00..000000000
--- a/dom/base/test/test_dialogArguments.html
+++ /dev/null
@@ -1,31 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
- <title>Test for Bug 1019761</title>
- <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
- <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-
- <meta http-equiv="content-type" content="text/html; charset=utf-8">
-</head>
-<body>
-<script type="application/javascript">
-
-/*
- Tests whether Firefox crashes when accessing the dialogArguments property
- of a modal window that has been closed.
-*/
-SimpleTest.waitForExplicitFinish();
-
-function openModal() {
- showModalDialog("javascript:opener.winRef = window; \
- window.opener.setTimeout(\'winRef.dialogArguments;\', 0);\
- window.close();");
-
- ok(true, "dialogArguments did not cause a crash.");
- SimpleTest.finish();
-}
-
-window.onload = openModal;
-</script>
-</body>
-</html>
diff --git a/dom/base/test/test_mutationobservers.html b/dom/base/test/test_mutationobservers.html
index bde07c79c..7e4c99423 100644
--- a/dom/base/test/test_mutationobservers.html
+++ b/dom/base/test/test_mutationobservers.html
@@ -362,7 +362,7 @@ function testChildList5() {
is(records[5].previousSibling, c3, "");
is(records[5].nextSibling, c5, "");
observer.disconnect();
- then(testAdoptNode);
+ then(testNestedMutations);
m = null;
});
m.observe(div, { childList: true, subtree: true });
@@ -375,6 +375,37 @@ function testChildList5() {
div.appendChild(emptyDF); // empty document shouldn't cause mutation records
}
+function testNestedMutations() {
+ div.textContent = null;
+ div.appendChild(document.createTextNode("foo"));
+ var m2WasCalled = false;
+ m = new M(function(records, observer) {
+ is(records[0].type, "characterData", "Should have got characterData");
+ observer.disconnect();
+ m = null;
+ m3 = new M(function(records, observer) {
+ ok(m2WasCalled, "m2 should have been called before m3!");
+ is(records[0].type, "characterData", "Should have got characterData");
+ observer.disconnect();
+ then(testAdoptNode);
+ m3 = null;
+ });
+ m3.observe(div, { characterData: true, subtree: true});
+ div.firstChild.data = "foo";
+ });
+ m2 = new M(function(records, observer) {
+ m2WasCalled = true;
+ is(records[0].type, "characterData", "Should have got characterData");
+ observer.disconnect();
+ m2 = null;
+ });
+ m2.observe(div, { characterData: true, subtree: true});
+ div.appendChild(document.createTextNode("foo"));
+ m.observe(div, { characterData: true, subtree: true });
+
+ div.firstChild.data = "bar";
+}
+
function testAdoptNode() {
var d1 = document.implementation.createHTMLDocument(null);
var d2 = document.implementation.createHTMLDocument(null);
@@ -484,28 +515,6 @@ function testSyncXHR() {
function testSyncXHR2() {
ok(callbackHandled, "Should have called the mutation callback!");
- then(testModalDialog);
-}
-
-function testModalDialog() {
- var didHandleCallback = false;
- div.innerHTML = "<span>1</span><span>2</span>";
- m = new M(function(records, observer) {
- is(records[0].type, "childList", "Should have got childList");
- is(records[0].removedNodes.length, 2, "Should have got removedNodes");
- is(records[0].addedNodes.length, 1, "Should have got addedNodes");
- observer.disconnect();
- m = null;
- didHandleCallback = true;
- });
- m.observe(div, { childList: true });
- div.innerHTML = "<span><span>foo</span></span>";
- try {
- window.showModalDialog("mutationobserver_dialog.html");
- ok(didHandleCallback, "Should have called the callback while showing modal dialog!");
- } catch(e) {
- todo(false, "showModalDialog not implemented on this platform");
- }
then(testTakeRecords);
}