Truly independent web browser
Tests/LibWeb: Import WPT tests for windows of removed iframes
Andreas Kling1f256779eaff
diff --git a/Tests/LibWeb/TestConfig.ini b/Tests/LibWeb/TestConfig.iniindex ad032527b2e..f5ddaba388e 100644--- a/Tests/LibWeb/TestConfig.ini+++ b/Tests/LibWeb/TestConfig.ini@@ -161,6 +161,9 @@ Text/input/wpt-import/html/webappapis/user-prompts/print-during-unload.html; Opens a popup by a root-relative URL, which needs an HTTP origin.Text/input/wpt-import/html/semantics/embedded-content/the-iframe-element/sandbox-inherit-to-blank-document-unsandboxed-frame.html+; Loads an iframe from a relative URL with an .htm extension, which needs an HTTP origin.+Text/input/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe-synchronously-discard.html+; Calls reload() on a child window's Location, which requires a shared tuple origin.Text/input/wpt-import/html/browsers/history/the-location-interface/reload_document_write.htmldiff --git a/Tests/LibWeb/Text/expected/wpt-import/html/browsers/windows/nested-browsing-contexts/window-parent-null.txt b/Tests/LibWeb/Text/expected/wpt-import/html/browsers/windows/nested-browsing-contexts/window-parent-null.txtnew file mode 100644index 00000000000..9259aaeca86--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/html/browsers/windows/nested-browsing-contexts/window-parent-null.txt@@ -0,0 +1,7 @@+Harness status: OK++Found 2 tests++2 Fail+Fail `window.parent` is null when browsing context container element removed+Fail `window.parent` null when parent browsing context container removed\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/html/browsers/windows/nested-browsing-contexts/window-top-null.txt b/Tests/LibWeb/Text/expected/wpt-import/html/browsers/windows/nested-browsing-contexts/window-top-null.txtnew file mode 100644index 00000000000..69bac9c9159--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/html/browsers/windows/nested-browsing-contexts/window-top-null.txt@@ -0,0 +1,7 @@+Harness status: OK++Found 2 tests++2 Fail+Fail `window.top` is null when browsing context container element removed+Fail `window.top`null when any ancestor browsing context container removed\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe-append-to-child-document.txt b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe-append-to-child-document.txtnew file mode 100644index 00000000000..348202de80e--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe-append-to-child-document.txt@@ -0,0 +1,6 @@+Harness status: OK++Found 1 tests++1 Fail+Fail Append iframe element to its own child document\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe-synchronously-discard.txt b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe-synchronously-discard.txtnew file mode 100644index 00000000000..c7c962b8a52--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe-synchronously-discard.txt@@ -0,0 +1,6 @@+Harness status: OK++Found 1 tests++1 Fail+Fail IFrame discards are processed synchronously\ No newline at end of filediff --git a/Tests/LibWeb/Text/input/wpt-import/html/browsers/windows/nested-browsing-contexts/window-parent-null.html b/Tests/LibWeb/Text/input/wpt-import/html/browsers/windows/nested-browsing-contexts/window-parent-null.htmlnew file mode 100644index 00000000000..8093c735952--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/html/browsers/windows/nested-browsing-contexts/window-parent-null.html@@ -0,0 +1,66 @@+<!doctype html>+<meta charset="utf-8">+<title>window.parent: `null`</title>+<script src="../../../../resources/testharness.js"></script>+<script src="../../../../resources/testharnessreport.js"></script>+<div id="log"></div>+<script>+async_test(t => {+ var iframe = document.createElement('iframe');+ iframe.onload = t.step_func_done(() => {+ var iWindow = iframe.contentWindow;+ assert_equals(iWindow.parent, window);+ document.body.removeChild(iframe);+ assert_equals(iWindow.parent, null);+ });++ document.body.appendChild(iframe);+}, '`window.parent` is null when browsing context container element removed');++async_test(t => {+ var iframe = document.createElement('iframe');+ var iframe2, removedEl;++ var testFunc = t.step_func(() => {+ var frameWindow = iframe.contentWindow;+ var frame2Window = iframe2.contentWindow;++ assert_equals(frameWindow.parent, window);+ assert_equals(frame2Window.parent, frameWindow);++ iframe.removeEventListener('load', nestFrame);+ iframe2.removeEventListener('load', testFunc);+ removedEl = document.body.removeChild(iframe);++ assert_equals(frameWindow.parent, null);+ assert_equals(frame2Window.parent, null);++ removedEl.addEventListener('load', t.step_func_done(() => {+ // reattached iframe's browsing context will report window.parent again+ assert_equals(removedEl.contentWindow.parent, window);+ // The following window s are no longer referenced by active browsing contexts+ assert_equals(frameWindow.parent, null);+ assert_equals(frame2Window.parent, null);+ // Per #the-iframe-element, reattaching a removed iframe will result in the+ // browser creating a new browsing context once again, with a fresh+ // document in our case, so the second iframe or any other elements+ // previously added to iframe.contentDocument will be gone+ assert_equals(removedEl.contentDocument.querySelector('iframe'), null);+ assert_equals(removedEl.contentDocument.querySelector('hr'), null);+ }));+ document.body.appendChild(removedEl);+ });++ var nestFrame = function () {+ iframe.contentDocument.body.appendChild(document.createElement('hr'));+ iframe2 = iframe.contentDocument.createElement('iframe');+ // Workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=1229707+ iframe2.src = '../../../../common/blank.html';+ iframe2.addEventListener('load', testFunc);+ iframe.contentDocument.body.appendChild(iframe2);+ };++ iframe.addEventListener('load', nestFrame);+ document.body.appendChild(iframe);+}, '`window.parent` null when parent browsing context container removed');+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/html/browsers/windows/nested-browsing-contexts/window-top-null.html b/Tests/LibWeb/Text/input/wpt-import/html/browsers/windows/nested-browsing-contexts/window-top-null.htmlnew file mode 100644index 00000000000..1ea2bc1e899--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/html/browsers/windows/nested-browsing-contexts/window-top-null.html@@ -0,0 +1,66 @@+<!doctype html>+<meta charset="utf-8">+<title>window.top: `null`</title>+<script src="../../../../resources/testharness.js"></script>+<script src="../../../../resources/testharnessreport.js"></script>+<div id="log"></div>+<script>+async_test(function (t) {+ var iframe = document.createElement('iframe');+ iframe.onload = t.step_func_done(() => {+ var iWindow = iframe.contentWindow;+ /**+ * `top` should return the top-level browsing context but will return+ * `null` if none exists, such as when any of the BC's ancestor browsing+ * context container's document elements are disconnected/removed.+ */+ assert_equals(iWindow.top, window);+ document.body.removeChild(iframe);+ assert_equals(iWindow.top, null);+ });++ document.body.appendChild(iframe);+}, '`window.top` is null when browsing context container element removed');++async_test(t => {+ var iframe = document.createElement('iframe');+ var iframe2, removedEl;++ var testFunc = t.step_func(() => {+ var frameWindow = iframe.contentWindow;+ var frame2Window = iframe2.contentWindow;++ assert_equals(frameWindow.top, window);+ assert_equals(frame2Window.top, window);++ iframe.removeEventListener('load', nestFrame);+ iframe2.removeEventListener('load', testFunc);++ removedEl = document.body.removeChild(iframe);++ assert_equals(frameWindow.top, null);+ assert_equals(frame2Window.top, null);++ removedEl.addEventListener('load', t.step_func_done(() => {+ // reattached iframe's browsing context will report window.top+ assert_equals(removedEl.contentWindow.top, window);+ // removed/re-added iframes will have new browsing context / window+ assert_equals(frameWindow.top, null);+ assert_equals(frame2Window.top, null);+ }));++ document.body.appendChild(removedEl);+ });++ var nestFrame = function () {+ iframe2 = iframe.contentDocument.createElement('iframe');+ // Workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=1229707+ iframe2.src = '../../../../common/blank.html';+ iframe2.addEventListener('load', testFunc);+ iframe.contentDocument.body.appendChild(iframe2);+ };++ iframe.addEventListener('load', nestFrame);+ document.body.appendChild(iframe);+}, '`window.top`null when any ancestor browsing context container removed');+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe-append-to-child-document.html b/Tests/LibWeb/Text/input/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe-append-to-child-document.htmlnew file mode 100644index 00000000000..a23ce883141--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe-append-to-child-document.html@@ -0,0 +1,17 @@+<!doctype html>+<meta charset=utf-8>+<title>Append iframe element to its own child document</title>+<script src="../../../../resources/testharness.js"></script>+<script src="../../../../resources/testharnessreport.js"></script>+<iframe id=x></iframe>+<script>+test(function() {+ var iframe = document.getElementById('x');+ var childWindow = iframe.contentWindow;+ assert_equals(childWindow.parent, window);+ childWindow.document.body.appendChild(iframe);+ assert_equals(childWindow.parent, null);+ assert_equals(iframe.contentWindow, null);+ assert_equals(childWindow.document.body.firstChild, iframe);+});+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe-synchronously-discard.html b/Tests/LibWeb/Text/input/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe-synchronously-discard.htmlnew file mode 100644index 00000000000..fcfc5338695--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/html/semantics/embedded-content/the-iframe-element/iframe-synchronously-discard.html@@ -0,0 +1,32 @@+<!doctype html>+<meta charset=utf-8>+<title>IFrame discards are processed synchronously</title>+<body></body>+<script src="../../../../resources/testharness.js"></script>+<script src="../../../../resources/testharnessreport.js"></script>+<script>+ async_test(function(t) {+ var child = document.createElement("iframe");+ child.src = "support/blank.htm?1";+ child.onload = t.step_func(function () {+ var childWindow = child.contentWindow;+ var grandchild = childWindow.document.createElement("iframe");+ grandchild.src = "blank.htm?2";+ grandchild.onload = t.step_func(function () {+ var grandchildWindow = grandchild.contentWindow;+ assert_equals(child.contentWindow, childWindow, "child window");+ assert_equals(childWindow.parent, window, "child parentage");+ assert_equals(grandchild.contentWindow, grandchildWindow, "grandchild window");+ assert_equals(grandchildWindow.parent, childWindow, "grandchild parentage");+ document.body.removeChild(child);+ assert_equals(child.contentWindow, null, "child should be discarded");+ assert_equals(childWindow.parent, null, "child window should be discarded");+ assert_equals(grandchild.contentWindow, null, "grandchild should be discarded");+ assert_equals(grandchildWindow.parent, null, "grandchild window should be discarded");+ t.done();+ });+ childWindow.document.body.appendChild(grandchild);+ });+ document.body.appendChild(child);+ });+</script>