summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/dom/nodes/MutationObserver-document.html
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /testing/web-platform/tests/dom/nodes/MutationObserver-document.html
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'testing/web-platform/tests/dom/nodes/MutationObserver-document.html')
-rw-r--r--testing/web-platform/tests/dom/nodes/MutationObserver-document.html167
1 files changed, 167 insertions, 0 deletions
diff --git a/testing/web-platform/tests/dom/nodes/MutationObserver-document.html b/testing/web-platform/tests/dom/nodes/MutationObserver-document.html
new file mode 100644
index 000000000..4662b2345
--- /dev/null
+++ b/testing/web-platform/tests/dom/nodes/MutationObserver-document.html
@@ -0,0 +1,167 @@
+<!DOCTYPE HTML>
+<meta charset=utf-8>
+<title>MutationObservers: takeRecords</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="mutationobservers.js"></script>
+<h1>MutationObservers: document mutations</h1>
+<div id="log"></div>
+
+<script id='s001'>
+ var setupTest = async_test("setup test");
+ var insertionTest = async_test("parser insertion mutations");
+ var insertionTest2 = async_test("parser script insertion mutation");
+ var testCounter = 0;
+
+ function masterMO(sequence, obs) {
+ testCounter++;
+ if (testCounter == 1) {
+ insertionTest.step(
+ function () {
+ checkRecords(document, sequence,
+ [{type: "childList",
+ addedNodes: function () {
+ return [ document.getElementById("n00") ];
+ },
+ previousSibling: function () {
+ return document.getElementById("s001");
+ },
+ target: document.body},
+ {type: "childList",
+ addedNodes: function () {
+ return [ document.getElementById("s002") ];
+ },
+ previousSibling: function () {
+ return document.getElementById("n00");
+ },
+ target: document.body},
+ {type: "childList",
+ addedNodes: function () {
+ return [ document.getElementById("s002").firstChild ];
+ },
+ target: function () {
+ return document.getElementById("s002");
+ }}]);
+ });
+ } else if (testCounter == 2) {
+ insertionTest2.step(
+ function () {
+ checkRecords(document, sequence,
+ [{type: "childList",
+ addedNodes: function () {
+ return [ document.getElementById("inserted_script") ];
+ },
+ target: function () {
+ return document.getElementById("n00");
+ }},
+ {type: "childList",
+ addedNodes: function () {
+ return [ document.getElementById("inserted_element") ];
+ },
+ previousSibling: function () {
+ return document.getElementById("s002");
+ },
+ target: document.body}
+ ]);
+ });
+ }
+ }
+ var document_observer;
+ var newElement;
+ setupTest.step(function() {
+ document_observer = new MutationObserver(masterMO);
+ newElement = document.createElement("span");
+ document_observer.observe(document, {subtree:true,childList:true});
+ newElement.id = "inserted_element";
+ newElement.setAttribute("style", "display: none");
+ newElement.textContent = "my new span for n00";
+ });
+</script><p id='n00'></p><script id='s002'>
+ var newScript = document.createElement("script");
+ setupTest.step(function() {
+ newScript.textContent = "document.body.appendChild(newElement);";
+ newScript.id = "inserted_script";
+ document.getElementById("n00").appendChild(newScript);
+ });
+ if (testCounter < 1) {
+ insertionTest.step(
+ function () {
+ assert_unreached("document observer did not trigger");
+ });
+ }
+</script><script id='s003'>
+ setupTest.step(function() {
+ document_observer.disconnect();
+ });
+ if (testCounter < 2) {
+ insertionTest2.step(
+ function () {
+ assert_unreached("document observer did not trigger");
+ });
+ }
+ insertionTest.done();
+ insertionTest2.done();
+</script>
+
+<p id='n012'></p><div id='d01'>
+<script id='s011'>
+ var removalTest = async_test("removal of parent during parsing");
+ var d01 = document.getElementById("d01");
+ testCounter = 0;
+
+ function removalMO(sequence, obs) {
+ testCounter++;
+ if (testCounter == 1) {
+ removalTest.step(
+ function () {
+ checkRecords(document, sequence,
+ [{type: "childList",
+ removedNodes: function () {
+ return [ d01 ];
+ },
+ previousSibling: function () {
+ return document.getElementById("n012");
+ },
+ target: document.body}]);
+ });
+ } else if (testCounter == 2) {
+ removalTest.step(
+ function () {
+ checkRecords(document, sequence,
+ [{type: "childList",
+ addedNodes: function () {
+ return [ document.getElementById("s012") ];
+ },
+ previousSibling: function () {
+ return document.getElementById("n012");
+ },
+ target: document.body},
+ {type: "childList",
+ addedNodes: function () {
+ return [ document.getElementById("s012").firstChild ];
+ },
+ target: function () {
+ return document.getElementById("s012");
+ }}]);
+ });
+ }
+ }
+ var document2_observer;
+ setupTest.step(function() {
+ document2_observer = new MutationObserver(removalMO);
+ document2_observer.observe(document, {subtree:true,childList:true});
+ d01.parentNode.removeChild(d01);
+ });
+</script><p id='n01'></p></div><script id='s012'>
+ setupTest.step(function() {
+ document2_observer.disconnect();
+ });
+ if (testCounter < 2) {
+ removalTest.step(
+ function () {
+ assert_unreached("document observer did not trigger");
+ });
+ }
+ removalTest.done();
+ setupTest.done();
+</script>