Bug 1258872 - Port test_mutationobserver_anonymous.html to mochitest-plain so that it can be turned on in e10s mode; r=mrbkap

This commit is contained in:
Ehsan Akhgari 2016-03-21 17:26:52 -04:00
Родитель 3b9ddbf3a9
Коммит 0e87b6fb88
4 изменённых файлов: 39 добавлений и 23 удалений

Просмотреть файл

@ -64,7 +64,6 @@ skip-if = buildapp == 'mulet'
[test_cpows.xul] [test_cpows.xul]
skip-if = buildapp == 'mulet' skip-if = buildapp == 'mulet'
[test_document_register.xul] [test_document_register.xul]
[test_mutationobserver_anonymous.html]
[test_registerElement_content.xul] [test_registerElement_content.xul]
[test_registerElement_ep.xul] [test_registerElement_ep.xul]
[test_domparsing.xul] [test_domparsing.xul]

Просмотреть файл

@ -793,6 +793,7 @@ skip-if = (os != 'b2g' && os != 'android') # meta-viewport tag support is mob
[test_mozfiledataurl.html] [test_mozfiledataurl.html]
skip-if = buildapp == 'mulet' || buildapp == 'b2g' || toolkit == 'android' #TIMED_OUT skip-if = buildapp == 'mulet' || buildapp == 'b2g' || toolkit == 'android' #TIMED_OUT
[test_mozMatchesSelector.html] [test_mozMatchesSelector.html]
[test_mutationobserver_anonymous.html]
[test_mutationobservers.html] [test_mutationobservers.html]
skip-if = buildapp == 'b2g' # b2g(bug 901385, showmodaldialog) b2g-debug(bug 901385, showmodaldialog) b2g-desktop(bug 901385, showmodaldialog) skip-if = buildapp == 'b2g' # b2g(bug 901385, showmodaldialog) b2g-debug(bug 901385, showmodaldialog) b2g-desktop(bug 901385, showmodaldialog)
[test_nodelist_holes.html] [test_nodelist_holes.html]

Просмотреть файл

@ -5,10 +5,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1034110
--> -->
<head> <head>
<title>Test for Bug 1034110</title> <title>Test for Bug 1034110</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/ChromeUtils.js"></script> <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
</head> </head>
<body> <body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1034110">Mozilla Bug 1034110</a> <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1034110">Mozilla Bug 1034110</a>
@ -29,26 +28,21 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1034110
/** Test for Bug 1034110 **/ /** Test for Bug 1034110 **/
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
const {Cc, Ci, Cu} = SpecialPowers;
function getWalker(node) { function getWalker(node) {
let walker = Cc["@mozilla.org/inspector/deep-tree-walker;1"].createInstance(Ci.inIDeepTreeWalker); return SpecialPowers.createDOMWalker(node, true);
walker.showAnonymousContent = true;
walker.init(node.ownerDocument, Ci.nsIDOMNodeFilter.SHOW_ALL);
walker.currentNode = node;
return walker;
} }
function getFirstChild(parent) { function getFirstChild(parent) {
return SpecialPowers.unwrap(getWalker(parent).firstChild()); return SpecialPowers.unwrap(getWalker(parent).firstChild);
} }
function getLastChild(parent) { function getLastChild(parent) {
return SpecialPowers.unwrap(getWalker(parent).lastChild()); return SpecialPowers.unwrap(getWalker(parent).lastChild);
} }
function assertSamePseudoElement(which, node1, node2) { function assertSamePseudoElement(which, node1, node2) {
is(node1.nodeName, "_moz_generated_content_" + which, is(SpecialPowers.wrap(node1).nodeName, "_moz_generated_content_" + which,
"Correct pseudo element type"); "Correct pseudo element type");
is(node1, node2, is(node1, node2,
"Referencing the same ::after element"); "Referencing the same ::after element");
@ -73,7 +67,7 @@ function testOneAdded() {
testAddedAndRemoved(); testAddedAndRemoved();
}); });
m.observe(parent, { nativeAnonymousChildList: true}); SpecialPowers.observeMutationEvents(m, parent, true);
parent.className = "before"; parent.className = "before";
} }
@ -100,7 +94,7 @@ function testAddedAndRemoved() {
testRemoved(); testRemoved();
}); });
m.observe(parent, { nativeAnonymousChildList: true}); SpecialPowers.observeMutationEvents(m, parent, true);
parent.className = "after"; parent.className = "after";
} }
@ -120,7 +114,7 @@ function testRemoved() {
testMultipleAdded(); testMultipleAdded();
}); });
m.observe(parent, { nativeAnonymousChildList: true }); SpecialPowers.observeMutationEvents(m, parent, true);
parent.className = ""; parent.className = "";
} }
@ -145,7 +139,7 @@ function testMultipleAdded() {
testRemovedDueToDisplay(); testRemovedDueToDisplay();
}); });
m.observe(parent, { nativeAnonymousChildList: true }); SpecialPowers.observeMutationEvents(m, parent, true);
parent.className = "before after"; parent.className = "before after";
} }
@ -172,7 +166,7 @@ function testRemovedDueToDisplay() {
testAddedDueToDisplay(); testAddedDueToDisplay();
}); });
m.observe(parent, { nativeAnonymousChildList: true }); SpecialPowers.observeMutationEvents(m, parent, true);
parent.style.display = "none"; parent.style.display = "none";
} }
@ -197,7 +191,7 @@ function testAddedDueToDisplay() {
testDifferentTargetNoSubtree(); testDifferentTargetNoSubtree();
}); });
m.observe(parent, { nativeAnonymousChildList: true }); SpecialPowers.observeMutationEvents(m, parent, true);
parent.style.display = "block"; parent.style.display = "block";
} }
@ -207,7 +201,7 @@ function testDifferentTargetNoSubtree() {
ok(false, ok(false,
"No mutation should fire when observing on a parent without subtree option."); "No mutation should fire when observing on a parent without subtree option.");
}); });
m.observe(document, { nativeAnonymousChildList: true }); SpecialPowers.observeMutationEvents(m, document, true);
parent.style.display = "none"; parent.style.display = "none";
// Wait for the actual mutation to come through, making sure that // Wait for the actual mutation to come through, making sure that
@ -218,7 +212,7 @@ function testDifferentTargetNoSubtree() {
observer.disconnect(); observer.disconnect();
testSubtree(); testSubtree();
}); });
m2.observe(parent, { nativeAnonymousChildList: true }); SpecialPowers.observeMutationEvents(m2, parent, true);
} }
function testSubtree() { function testSubtree() {
@ -241,7 +235,7 @@ function testSubtree() {
observer.disconnect(); observer.disconnect();
SimpleTest.finish(); SimpleTest.finish();
}); });
m.observe(document, { nativeAnonymousChildList: true, subtree: true }); SpecialPowers.observeMutationEvents(m, document, true, true);
parent.style.display = "block"; parent.style.display = "block";
} }

Просмотреть файл

@ -2023,6 +2023,28 @@ SpecialPowersAPI.prototype = {
}; };
return this._pu; return this._pu;
}, },
createDOMWalker: function(node, showAnonymousContent) {
node = unwrapIfWrapped(node);
let walker = Cc["@mozilla.org/inspector/deep-tree-walker;1"].
createInstance(Ci.inIDeepTreeWalker);
walker.showAnonymousContent = showAnonymousContent;
walker.init(node.ownerDocument, Ci.nsIDOMNodeFilter.SHOW_ALL);
walker.currentNode = node;
return {
get firstChild() {
return wrapIfUnwrapped(walker.firstChild());
},
get lastChild() {
return wrapIfUnwrapped(walker.lastChild());
},
};
},
observeMutationEvents: function(mo, node, nativeAnonymousChildList, subtree) {
unwrapIfWrapped(mo).observe(unwrapIfWrapped(node),
{nativeAnonymousChildList, subtree});
},
}; };
this.SpecialPowersAPI = SpecialPowersAPI; this.SpecialPowersAPI = SpecialPowersAPI;