2 * Copyright 2016 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 function nav_parent_test() {
20 external.trace("Running _parent navigation tests...");
22 var iframe = document.getElementById("testframe");
23 var subframe = iframe.contentWindow.document.createElement("iframe");
25 subframe.onload = function() {
26 var doc = subframe.contentWindow.document;
27 doc.body.innerHTML = '<a href="blank2.html" id="aid" target="_parent">test</a>';
28 doc.getElementById("aid").click();
31 iframe.onload = function() {
33 var href = iframe.contentWindow.location.href;
34 ok(/.*blank2.html/.test(href), "Unexpected href " + href);
38 iframe.contentWindow.document.body.appendChild(subframe);
39 subframe.src = "blank.html";
42 function window_navigate_test() {
43 external.trace("Running window.navigate() tests...");
45 var iframe = document.getElementById("testframe");
47 iframe.onload = function() {
49 var href = iframe.contentWindow.location.href;
50 ok(href === "about:blank", "Unexpected href " + href);
54 iframe.contentWindow.navigate("about:blank");
57 function window_open_self_test() {
58 external.trace("Running window.open(_self) tests...");
60 var iframe = document.getElementById("testframe");
61 var iframe_window = iframe.contentWindow;
63 iframe.onload = function() {
65 var href = iframe.contentWindow.location.href;
66 ok(/.*blank.html\?window_open_self/.test(href), "Unexpected href " + href);
67 ok(iframe.contentWindow === iframe_window, "iframe.contentWindow !== iframe_window");
71 iframe_window.open("blank.html?window_open_self", "_self");
74 function detached_src_test() {
75 var iframe = document.createElement("iframe");
76 var onload_called = false;
78 iframe.onload = function() {
83 iframe.src = "blank.html";
84 document.body.appendChild(iframe);
85 ok(onload_called === false, "called onload too early?");
88 function detached_iframe_doc() {
89 document.body.innerHTML = "";
91 var iframe = document.createElement("iframe");
94 function expect_exception(f, is_todo) {
97 todo_wine_if(is_todo).ok(false, "expected exception");
101 iframe.onload = guard(function() {
102 origDoc = iframe.contentWindow.document;
103 iframe.onload = guard(function () {
104 var doc = iframe.contentWindow.document;
106 ok(/.*blank2.html/.test(doc.URL), "Unexpected iframe doc URL " + doc.URL);
108 if (doc.documentMode >= 9) {
110 origDoc != null; // it's not allowed to even compare detached document
112 ok(false, "expected exception");
116 ok(doc === origDoc, "doc != origDoc");
119 expect_exception(function() { origDoc.onclick; }, true);
120 expect_exception(function() { origDoc.toString; }, true);
121 expect_exception(function() { origDoc.toString(); }, true);
122 expect_exception(function() { origDoc.URL; });
126 iframe.src = "blank2.html";
129 iframe.src = "blank.html";
130 document.body.appendChild(iframe);
133 function init_test_iframe() {
134 var iframe = document.createElement("iframe");
136 iframe.onload = next_test;
137 iframe.id = "testframe";
138 iframe.src = "about:blank";
139 document.body.appendChild(iframe);
145 window_navigate_test,
146 window_open_self_test,