summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/form-submit-cross-frame.html
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/form-submit-cross-frame.html')
-rw-r--r--testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/form-submit-cross-frame.html40
1 files changed, 40 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/form-submit-cross-frame.html b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/form-submit-cross-frame.html
new file mode 100644
index 0000000000..d647e6ad06
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/form-submit-cross-frame.html
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="resources/helpers.js"></script>
+
+<form target="the-frame">
+ <input type="hidden" name="pushed">
+</form>
+
+<script>
+"use strict";
+promise_test(async t => {
+ const startingHistoryLength = history.length;
+
+ const form = document.querySelector("form");
+ const frameEndingURL = absoluteURL("resources/slow-message-source-with-history-and-location.html?pushed=");
+ form.action = frameEndingURL;
+
+ const frameStartingCode = `
+ window.onload = () => { window.onloadFired = true; };
+ parent.postMessage({ historyLength: history.length, locationHref: location.href }, "*");
+ parent.document.querySelector("form").submit();
+ `;
+
+ const frameStartingURL = codeInjectorURL(frameStartingCode);
+ const frame = insertIframe(t, frameStartingURL, "the-frame");
+ t.add_cleanup(() => frame.remove()); // helps avoid waiting for the slow load to finish the tests
+ assert_equals(history.length, startingHistoryLength, "Inserting frame must not change history.length");
+
+ const frameBeforeLoadedMessage = await waitForMessage();
+ assert_equals(frameBeforeLoadedMessage.historyLength, startingHistoryLength, "frame's starting history.length");
+ assert_equals(frameBeforeLoadedMessage.locationHref, frame.src, "frame's starting location.href");
+ assert_equals(frame.contentWindow.onloadFired, undefined, "frame's onload not fired yet");
+
+ const frameAfterFormSubmitMessage = await waitForMessage();
+ assert_equals(frameAfterFormSubmitMessage.historyLength, startingHistoryLength + 1, "frame's after-submit history.length");
+ assert_equals(frameAfterFormSubmitMessage.locationHref, frameEndingURL, "frame's after-submit location.href");
+}, "No replace before load, triggered by cross-iframe formElement.submit()");
+</script>