Skip to content

Commit db6fcb5

Browse files
mikewestchromium-wpt-export-bot
authored andcommitted
[Navigation API] Fix cross-origin leak of sourceElement.
This CL prevents a cross-origin initiator's Element from being exposed via NavigateEvent.sourceElement during same-document navigations. Bug: 502410911 Change-Id: I756dbd4876afc0db7617f18772e0055962804c18 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7762284 Reviewed-by: Nate Chapin <japhet@chromium.org> Commit-Queue: Mike West <mkwst@chromium.org> Cr-Commit-Position: refs/heads/main@{#1615710}
1 parent 95c95ff commit db6fcb5

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!doctype html>
2+
<script>
3+
navigation.onnavigate = e => {
4+
if (e.destination.url.includes("#test")) {
5+
window.parent.postMessage({
6+
type: "result",
7+
sourceElementIsNull: e.sourceElement === null,
8+
sourceElementName: e.sourceElement ? e.sourceElement.tagName : "null"
9+
}, "*");
10+
}
11+
};
12+
window.parent.postMessage({ type: "ready" }, "*");
13+
</script>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!doctype html>
2+
<script src="/resources/testharness.js"></script>
3+
<script src="/resources/testharnessreport.js"></script>
4+
<iframe id="theFrame" name="theFrame" src="http://{{domains[www1]}}:{{ports[http][0]}}/navigation-api/navigate-event/resources/echo-sourceElement.html"></iframe>
5+
<script>
6+
async_test(t => {
7+
window.addEventListener("message", t.step_func(e => {
8+
if (e.data.type === "ready") {
9+
const a = document.createElement("a");
10+
a.href = document.getElementById("theFrame").src + "#test";
11+
a.target = "theFrame";
12+
document.body.appendChild(a);
13+
a.click();
14+
} else if (e.data.type === "result") {
15+
assert_true(e.data.sourceElementIsNull, "sourceElement must be null for cross-origin initiators (it was " + e.data.sourceElementName + ")");
16+
t.done();
17+
}
18+
}));
19+
}, "NavigateEvent.sourceElement should be null for cross-origin same-document initiators");
20+
</script>

0 commit comments

Comments
 (0)