зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1535931
[wpt PR 15812] - Selection and document.open(), a=testonly
Automatic update from web-platform-tests Selection and document.open() -- wpt-commits: 0ea8f9e9da1dadf3fd23e20621f880d6acc6c0ac wpt-pr: 15812
This commit is contained in:
Родитель
14bb497a50
Коммит
111e7badac
|
@ -6,39 +6,23 @@
|
|||
<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.
|
||||
const iframe = document.createElement("iframe");
|
||||
async_test(t => {
|
||||
iframe.onload = t.step_func_done(() => {
|
||||
const originalSelection = iframe.contentWindow.getSelection();
|
||||
assert_equals(originalSelection.rangeCount, 0, "rangeCount must initially be 0");
|
||||
iframe.contentDocument.body.appendChild(iframe.contentDocument.createTextNode("foo"));
|
||||
const range = iframe.contentDocument.createRange();
|
||||
range.selectNodeContents(iframe.contentDocument.body);
|
||||
iframe.contentWindow.getSelection().addRange(range);
|
||||
assert_equals(originalSelection.rangeCount, 1, "rangeCount must be 1 after adding a range");
|
||||
|
||||
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();
|
||||
|
||||
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();
|
||||
assert_equals(iframe.contentWindow.getSelection(), originalSelection, "After document.open(), the Selection object must be the same");
|
||||
assert_equals(iframe.contentWindow.getSelection().rangeCount, 1, "After document.open(), rangeCount must still be 1");
|
||||
document.body.removeChild(iframe);
|
||||
};
|
||||
document.body.appendChild(iframe);
|
||||
});
|
||||
document.body.appendChild(iframe);
|
||||
}, "Selection must not be replaced with a new object after document.open()");
|
||||
</script>
|
||||
|
|
Загрузка…
Ссылка в новой задаче