Revision bca58b0cef32b342eece2c135fdc62e32b69e557 authored by moz-wptsync-bot on 16 March 2018, 13:38:52 UTC, committed by moz-wptsync-bot on 20 March 2018, 02:29:46 UTC
bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1445883 gecko-commit: 0f81334efa0a008db8931a41eef2d26a77d0e800 gecko-integration-branch: mozilla-inbound gecko-reviewers: smaug
1 parent c51eaff
Document-open.html
<!doctype html>
<title>Selection Document.open() tests</title>
<div id=log></div>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script>
"use strict";
// This tests the HTML spec requirement "Replace the Document's singleton
// objects with new instances of those objects. (This includes in particular
// the Window, Location, History, ApplicationCache, and Navigator, objects, the
// various BarProp objects, the two Storage objects, the various HTMLCollection
// objects, and objects defined by other specifications, like Selection and the
// document's UndoManager. It also includes all the Web IDL prototypes in the
// JavaScript binding, including the Document object's prototype.)" in the
// document.open() algorithm.
var iframe = document.createElement("iframe");
var t = async_test("Selection must be replaced with a new object after document.open()");
iframe.onload = function() {
t.step(function() {
var originalSelection = iframe.contentWindow.getSelection();
assert_equals(originalSelection.rangeCount, 0,
"Sanity check: rangeCount must be initially 0");
iframe.contentDocument.body.appendChild(
iframe.contentDocument.createTextNode("foo"));
var range = iframe.contentDocument.createRange();
range.selectNodeContents(iframe.contentDocument.body);
iframe.contentWindow.getSelection().addRange(range);
assert_equals(originalSelection.rangeCount, 1,
"Sanity check: rangeCount must be 1 after adding a range");
iframe.contentDocument.open();
assert_not_equals(iframe.contentWindow.getSelection(), originalSelection,
"After document.open(), the Selection object must no longer be the same");
assert_equals(iframe.contentWindow.getSelection().rangeCount, 0,
"After document.open(), rangeCount must be 0 again");
});
t.done();
document.body.removeChild(iframe);
};
document.body.appendChild(iframe);
</script>
Computing file changes ...