-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure iframe requests include Referer when location.replace or locat…
…ion.assign is called https://bugs.webkit.org/show_bug.cgi?id=263072 Reviewed by Chris Dumez and Alex Christensen. When the loader for a Frame (e.g, an iframe) has no referrer, then this change causes the loader's referrer to be set to the URL of its parent Frame’s Document. That in turn ensures the associated request is sent with a Referer header — including in the case where a document calls location.replace or location.assign on an iframe element — which makes the WebKit behavior in this case interoperable with existing behavior in Gecko and Blink. Otherwise, without this change, no Referer header is sent in the associated request, which breaks interoperability with Gecko and Blink. * LayoutTests/imported/w3c/web-platform-tests/html/browsers/history/the-location-interface/assign-replace-from-iframe-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/browsers/history/the-location-interface/assign-replace-from-iframe.html: Added. * LayoutTests/imported/w3c/web-platform-tests/html/browsers/history/the-location-interface/assign-replace-from-top-to-nested-iframe-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/browsers/history/the-location-interface/assign-replace-from-top-to-nested-iframe.html: Added. * LayoutTests/imported/w3c/web-platform-tests/html/browsers/history/the-location-interface/assign-with-nested-iframe-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/browsers/history/the-location-interface/assign-with-nested-iframe.html: Added. * LayoutTests/imported/w3c/web-platform-tests/html/browsers/history/the-location-interface/replace-with-nested-iframe-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/html/browsers/history/the-location-interface/replace-with-nested-iframe.html: Added. * LayoutTests/imported/w3c/web-platform-tests/html/browsers/history/the-location-interface/resources/iframe-contents.sub.html: Added. * LayoutTests/imported/w3c/web-platform-tests/html/browsers/history/the-location-interface/resources/iframe-postmessage-to-parent-parent.sub.html: Added. * LayoutTests/imported/w3c/web-platform-tests/html/browsers/history/the-location-interface/resources/iframe-with-iframe.html: Added. * LayoutTests/imported/w3c/web-platform-tests/html/browsers/history/the-location-interface/resources/replace-or-assign-call-on-iframe.html: Added. * LayoutTests/imported/w3c/web-platform-tests/html/browsers/the-window-object/open-close/no_window_open_when_term_nesting_level_nonzero.window-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/webappapis/scripting/processing-model-2/unhandled-promise-rejections/promise-rejection-events-expected.txt: * Source/WebCore/page/LocalDOMWindow.cpp: (WebCore::LocalDOMWindow::setLocation): Canonical link: https://commits.webkit.org/270741@main
- Loading branch information
1 parent
fcf4ebb
commit 1350b59
Showing
15 changed files
with
189 additions
and
2 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
...ests/html/browsers/history/the-location-interface/assign-replace-from-iframe-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
PASS Browser sends Referer header in iframe request when location.replace is called from an iframe | ||
PASS Browser sends Referer header in iframe request when location.assign is called from an iframe | ||
|
31 changes: 31 additions & 0 deletions
31
...atform-tests/html/browsers/history/the-location-interface/assign-replace-from-iframe.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<!DOCTYPE HTML> | ||
<html> | ||
<head> | ||
<title>Referer with location.replace and location.assign</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
</head> | ||
<body> | ||
<iframe src="/resources/blank.html" hidden></iframe> | ||
<script> | ||
async_test(function(t) { | ||
function on_message(e) { | ||
const referrer = e.data; | ||
assert_equals(referrer, window.location.href); | ||
t.done(); | ||
} | ||
window.addEventListener('message', t.step_func(on_message), false); | ||
document.querySelector("iframe").contentWindow.location.replace("resources/iframe-contents.sub.html?replace"); | ||
}, "Browser sends Referer header in iframe request when location.replace is called from an iframe"); | ||
async_test(function(t) { | ||
function on_message(e) { | ||
const referrer = e.data; | ||
assert_equals(referrer, window.location.href); | ||
t.done(); | ||
} | ||
window.addEventListener('message', t.step_func(on_message), false); | ||
document.querySelector("iframe").contentWindow.location.assign("resources/iframe-contents.sub.html?assign"); | ||
}, "Browser sends Referer header in iframe request when location.assign is called from an iframe"); | ||
</script> | ||
</body> | ||
</html> |
4 changes: 4 additions & 0 deletions
4
...sers/history/the-location-interface/assign-replace-from-top-to-nested-iframe-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
PASS Browser sends Referer header in nested iframe request when location.replace is called on an iframe | ||
PASS Browser sends Referer header in nested iframe request when location.assign is called on an iframe | ||
|
36 changes: 36 additions & 0 deletions
36
...tml/browsers/history/the-location-interface/assign-replace-from-top-to-nested-iframe.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<!DOCTYPE HTML> | ||
<html> | ||
<head> | ||
<title>Referer with location.replace and location.assign with nested iframes</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
</head> | ||
<body> | ||
<iframe src="resources/iframe-with-iframe.html" hidden></iframe> | ||
<script> | ||
const iframe = document.querySelector("iframe"); | ||
async_test(function(t) { | ||
function on_message(e) { | ||
const referrer = e.data; | ||
assert_equals(referrer, iframe.contentWindow.location.href); | ||
t.done(); | ||
} | ||
window.addEventListener('message', t.step_func(on_message), false); | ||
window.addEventListener('load', function () { | ||
iframe.contentDocument.querySelector("iframe").contentWindow.location.replace("/resources/blank.html"); | ||
}, false); | ||
}, "Browser sends Referer header in nested iframe request when location.replace is called on an iframe"); | ||
async_test(function(t) { | ||
function on_message(e) { | ||
const referrer = e.data; | ||
assert_equals(referrer, iframe.contentWindow.location.href); | ||
t.done(); | ||
} | ||
window.addEventListener('message', t.step_func(on_message), false); | ||
window.addEventListener('load', function () { | ||
iframe.contentDocument.querySelector("iframe").contentWindow.location.replace("/resources/blank.html"); | ||
}, false); | ||
}, "Browser sends Referer header in nested iframe request when location.assign is called on an iframe"); | ||
</script> | ||
</body> | ||
</html> |
3 changes: 3 additions & 0 deletions
3
...tests/html/browsers/history/the-location-interface/assign-with-nested-iframe-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
PASS Browser sends Referer header when location.assign is called in iframe document on another nested iframe element | ||
|
21 changes: 21 additions & 0 deletions
21
...latform-tests/html/browsers/history/the-location-interface/assign-with-nested-iframe.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!DOCTYPE HTML> | ||
<html> | ||
<head> | ||
<title>Referer with location.assign and nested frames</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
</head> | ||
<body> | ||
<iframe src="resources/replace-or-assign-call-on-iframe.html?assign" hidden></iframe> | ||
<script> | ||
async_test(function(t) { | ||
function on_message(e) { | ||
const nestedIframeReferrer = e.data; | ||
assert_equals(nestedIframeReferrer, document.querySelector("iframe").contentWindow.location.href); | ||
t.done(); | ||
} | ||
window.addEventListener('message', t.step_func(on_message), false); | ||
}, "Browser sends Referer header when location.assign is called in iframe document on another nested iframe element"); | ||
</script> | ||
</body> | ||
</html> |
3 changes: 3 additions & 0 deletions
3
...ests/html/browsers/history/the-location-interface/replace-with-nested-iframe-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
PASS Browser sends Referer header when location.replace is called in iframe document on another nested iframe element | ||
|
21 changes: 21 additions & 0 deletions
21
...atform-tests/html/browsers/history/the-location-interface/replace-with-nested-iframe.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!DOCTYPE HTML> | ||
<html> | ||
<head> | ||
<title>Referer with location.replace and nested frames</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
</head> | ||
<body> | ||
<iframe src="resources/replace-or-assign-call-on-iframe.html?replace" hidden></iframe> | ||
<script> | ||
async_test(function(t) { | ||
function on_message(e) { | ||
const nestedIframeReferrer = e.data; | ||
assert_equals(nestedIframeReferrer, document.querySelector("iframe").contentWindow.location.href); | ||
t.done(); | ||
} | ||
window.addEventListener('message', t.step_func(on_message), false); | ||
}, "Browser sends Referer header when location.replace is called in iframe document on another nested iframe element"); | ||
</script> | ||
</body> | ||
</html> |
14 changes: 14 additions & 0 deletions
14
...orm-tests/html/browsers/history/the-location-interface/resources/iframe-contents.sub.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!DOCTYPE HTML> | ||
<html> | ||
<head> | ||
<title>Resource file for test of Referer with location.replace</title> | ||
</head> | ||
<body> | ||
<div></div> | ||
<script> | ||
const referer = "{{header_or_default(referer, missing)}}" | ||
window.parent.postMessage(referer); | ||
document.querySelector("div").textContent = `Referer header: ${referer}`; | ||
</script> | ||
</body> | ||
</html> |
14 changes: 14 additions & 0 deletions
14
...ers/history/the-location-interface/resources/iframe-postmessage-to-parent-parent.sub.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!DOCTYPE HTML> | ||
<html> | ||
<head> | ||
<title>Resource file for test of Referer with location.replace</title> | ||
</head> | ||
<body> | ||
<div></div> | ||
<script> | ||
const referer = "{{header_or_default(referer, missing)}}" | ||
window.parent.parent.postMessage(referer); | ||
document.querySelector("div").textContent = `Referer header: ${referer}`; | ||
</script> | ||
</body> | ||
</html> |
9 changes: 9 additions & 0 deletions
9
...form-tests/html/browsers/history/the-location-interface/resources/iframe-with-iframe.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<!DOCTYPE HTML> | ||
<html> | ||
<head> | ||
<title>Resource file for test of Referer with location.replace and location.assign</title> | ||
</head> | ||
<body> | ||
<iframe src="iframe-postmessage-to-parent-parent.sub.html"></iframe> | ||
</body> | ||
</html> |
20 changes: 20 additions & 0 deletions
20
...l/browsers/history/the-location-interface/resources/replace-or-assign-call-on-iframe.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!DOCTYPE HTML> | ||
<html> | ||
<head> | ||
<title>Referer with location.replace and location.assign</title> | ||
</head> | ||
<body> | ||
<iframe src="/resources/blank.html" hidden></iframe> | ||
<script> | ||
window.addEventListener('message', function (e) { | ||
const referrer = e.data; | ||
window.parent.postMessage(referrer); | ||
}); | ||
if (window.location.search === "?replace") { | ||
document.querySelector("iframe").contentWindow.location.replace("iframe-contents.sub.html?replace"); | ||
} else if (window.location.search === "?assign") { | ||
document.querySelector("iframe").contentWindow.location.assign("iframe-contents.sub.html?assign"); | ||
} | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters