dom/imptests/editing/selecttest/test_deleteFromDocument.html

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 <!doctype html>
michael@0 2 <title>Selection.deleteFromDocument() tests</title>
michael@0 3 <link rel=author title="Aryeh Gregor" href=ayg@aryeh.name>
michael@0 4 <p>To debug test failures, add a query parameter with the test id (like
michael@0 5 "?5"). Only that test will be run. Then you can look at the resulting
michael@0 6 iframes in the DOM.
michael@0 7 <div id=log></div>
michael@0 8 <script src=/resources/testharness.js></script>
michael@0 9 <script src=/resources/testharnessreport.js></script>
michael@0 10 <script src=common.js></script>
michael@0 11 <script>
michael@0 12 "use strict";
michael@0 13
michael@0 14 // We need to use explicit_done, because in Chrome 16 dev and Opera 12.00, the
michael@0 15 // second iframe doesn't block the load event -- even though it is added before
michael@0 16 // the load event.
michael@0 17 setup({explicit_done: true});
michael@0 18
michael@0 19 // Specified by WebIDL
michael@0 20 test(function() {
michael@0 21 assert_equals(Selection.prototype.deleteFromDocument.length, 0,
michael@0 22 "Selection.prototype.deleteFromDocument.length must equal 0");
michael@0 23 }, "Selection.prototype.deleteFromDocument.length must equal 0");
michael@0 24
michael@0 25 testDiv.parentNode.removeChild(testDiv);
michael@0 26
michael@0 27 // Test an empty selection too
michael@0 28 testRanges.unshift("empty");
michael@0 29
michael@0 30 var actualIframe = document.createElement("iframe");
michael@0 31
michael@0 32 var expectedIframe = document.createElement("iframe");
michael@0 33
michael@0 34 var referenceDoc = document.implementation.createHTMLDocument("");
michael@0 35 referenceDoc.removeChild(referenceDoc.documentElement);
michael@0 36
michael@0 37 actualIframe.onload = function() {
michael@0 38 expectedIframe.onload = function() {
michael@0 39 for (var i = 0; i < testRanges.length; i++) {
michael@0 40 if (location.search && i != Number(location.search)) {
michael@0 41 continue;
michael@0 42 }
michael@0 43
michael@0 44 test(function() {
michael@0 45 initializeIframe(actualIframe, testRanges[i]);
michael@0 46 initializeIframe(expectedIframe, testRanges[i]);
michael@0 47
michael@0 48 var actualRange = actualIframe.contentWindow.testRange;
michael@0 49 var expectedRange = expectedIframe.contentWindow.testRange;
michael@0 50
michael@0 51 assert_equals(actualIframe.contentWindow.unexpectedException, null,
michael@0 52 "Unexpected exception thrown when setting up Range for actual deleteFromDocument");
michael@0 53 assert_equals(expectedIframe.contentWindow.unexpectedException, null,
michael@0 54 "Unexpected exception thrown when setting up Range for simulated deleteFromDocument");
michael@0 55
michael@0 56 actualIframe.contentWindow.getSelection().removeAllRanges();
michael@0 57 if (testRanges[i] != "empty") {
michael@0 58 assert_equals(typeof actualRange, "object",
michael@0 59 "Range produced in actual iframe must be an object");
michael@0 60 assert_equals(typeof expectedRange, "object",
michael@0 61 "Range produced in expected iframe must be an object");
michael@0 62 assert_true(actualRange instanceof actualIframe.contentWindow.Range,
michael@0 63 "Range produced in actual iframe must be instanceof Range");
michael@0 64 assert_true(expectedRange instanceof expectedIframe.contentWindow.Range,
michael@0 65 "Range produced in expected iframe must be instanceof Range");
michael@0 66 actualIframe.contentWindow.getSelection().addRange(actualIframe.contentWindow.testRange);
michael@0 67 expectedIframe.contentWindow.testRange.deleteContents();
michael@0 68 }
michael@0 69 actualIframe.contentWindow.getSelection().deleteFromDocument();
michael@0 70
michael@0 71 assertNodesEqual(actualIframe.contentDocument, expectedIframe.contentDocument, "DOM contents");
michael@0 72 }, "Range " + i + ": " + testRanges[i]);
michael@0 73 }
michael@0 74 actualIframe.style.display = "none";
michael@0 75 expectedIframe.style.display = "none";
michael@0 76 done();
michael@0 77 };
michael@0 78 expectedIframe.src = "test-iframe.html";
michael@0 79 document.body.appendChild(expectedIframe);
michael@0 80 referenceDoc.appendChild(actualIframe.contentDocument.documentElement.cloneNode(true));
michael@0 81 };
michael@0 82 actualIframe.src = "test-iframe.html";
michael@0 83 document.body.appendChild(actualIframe);
michael@0 84
michael@0 85 function initializeIframe(iframe, endpoints) {
michael@0 86 while (iframe.contentDocument.firstChild) {
michael@0 87 iframe.contentDocument.removeChild(iframe.contentDocument.lastChild);
michael@0 88 }
michael@0 89 iframe.contentDocument.appendChild(iframe.contentDocument.implementation.createDocumentType("html", "", ""));
michael@0 90 iframe.contentDocument.appendChild(referenceDoc.documentElement.cloneNode(true));
michael@0 91 iframe.contentWindow.setupRangeTests();
michael@0 92 if (endpoints != "empty") {
michael@0 93 iframe.contentWindow.testRangeInput = endpoints;
michael@0 94 iframe.contentWindow.run();
michael@0 95 }
michael@0 96 }
michael@0 97 </script>

mercurial