blob: 9d170914e6516b2829f1872e001dd4cd08e30b4c [file] [log] [blame]
<!doctype html>
<title>Selection tests</title>
<div id=log></div>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></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
// algorithm.
var iframe = document.createElement("iframe");
var t = async_test("Selection must be replaced with a new object after");
iframe.onload = function() {
t.step(function() {
var originalSelection = iframe.contentWindow.getSelection();
assert_equals(originalSelection.rangeCount, 0,
"Sanity check: rangeCount must be initially 0");
var range = iframe.contentDocument.createRange();
assert_equals(originalSelection.rangeCount, 1,
"Sanity check: rangeCount must be 1 after adding a range");;
assert_not_equals(iframe.contentWindow.getSelection(), originalSelection,
"After, the Selection object must no longer be the same");
assert_equals(iframe.contentWindow.getSelection().rangeCount, 0,
"After, rangeCount must be 0 again");