Commit c3401fc0 authored by Mustaq Ahmed's avatar Mustaq Ahmed Committed by Commit Bot

Cleaup subframes used in wpt/html/user-activation/*.html.

Change-Id: I4a7dae4534339ec2f203efa3860d5b8a9e5e9ba4
TBR: lanwei@chromium.org
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1677127
Commit-Queue: Mustaq Ahmed <mustaq@chromium.org>
Reviewed-by: default avatarMustaq Ahmed <mustaq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#672262}
parent 25a5847c
......@@ -14,7 +14,7 @@
<body>
<h1>Clicking in iframe has activation state in child</h1>
<ol id="instructions">
<li>Click inside the red area.
<li>Click inside the light-grey area.
</ol>
<iframe id="child" width="200" height="200"></iframe>
<script>
......
......@@ -24,12 +24,12 @@
var child1 = document.getElementById("child1");
var child2 = document.getElementById("child2");
var is_child_four_loaded = false;
var is_child_five_loaded = false;
var is_child_two_loaded = false;
assert_false(navigator.userActivation.isActive);
assert_false(navigator.userActivation.hasBeenActive);
function tryClickInstructions() {
if (is_child_four_loaded && is_child_five_loaded)
if (is_child_four_loaded && is_child_two_loaded)
test_driver.click(document.getElementById('instructions'));
}
......@@ -52,15 +52,15 @@
assert_false(navigator.userActivation.hasBeenActive);
child2.contentWindow.postMessage('report', '*');
} else if (msg.type == 'child-five-loaded') {
} else if (msg.type == 'child-two-loaded') {
// state should be false after load
assert_false(msg.isActive);
assert_false(msg.hasBeenActive);
// click in parent document after both child frames load
is_child_five_loaded = true;
is_child_two_loaded = true;
tryClickInstructions();
} else if (msg.type == 'child-five-report') {
} else if (msg.type == 'child-two-report') {
assert_false(msg.isActive);
assert_false(msg.hasBeenActive);
......@@ -75,7 +75,7 @@
assert_true(navigator.userActivation.hasBeenActive);
// transfer user activation to the child frame
child1.contentWindow.postMessage("transfer_user_activation",
child1.contentWindow.postMessage("report",
{targetOrigin: "*", transferUserActivation: true});
// sender's activation state is updated synchronously
......@@ -83,7 +83,7 @@
assert_false(navigator.userActivation.hasBeenActive);
}));
child1.src = "http://{{domains[www]}}:{{ports[http][0]}}/html/user-activation/resources/child-four.html";
child2.src = "http://{{domains[www1]}}:{{ports[http][0]}}/html/user-activation/resources/child-five.html";
child2.src = "http://{{domains[www1]}}:{{ports[http][0]}}/html/user-activation/resources/child-two.html";
}, "Cross-origin user activation transfer through postMessages");
</script>
</body>
......
......@@ -48,7 +48,7 @@
assert_true(navigator.userActivation.hasBeenActive);
// transfer user activation to the child frame
child.contentWindow.postMessage("transfer_user_activation",
child.contentWindow.postMessage("report",
{targetOrigin: "*", transferUserActivation: true});
// sender's activation state is updated synchronously
......
......@@ -48,7 +48,7 @@
assert_true(navigator.userActivation.hasBeenActive);
// transfer user activation to the child frame
child.contentWindow.postMessage("transfer_user_activation",
child.contentWindow.postMessage("report",
{transferUserActivation: true});
// sender's activation state is updated synchronously
......
......@@ -22,7 +22,7 @@
function tryPostMessaging() {
if (is_page_loaded && is_child_four_loaded)
child.contentWindow.postMessage("transfer_user_activation", {transferUserActivation: true});
child.contentWindow.postMessage("report", {transferUserActivation: true});
}
window.addEventListener("message", t.step_func(event => {
......
<!DOCTYPE html>
<body style="background: red;">
<script>
window.parent.postMessage(JSON.stringify({"type": "child-five-loaded", "isActive": navigator.userActivation.isActive,
"hasBeenActive": navigator.userActivation.hasBeenActive}), "*");
window.addEventListener("message", event => {
if (event.source === window.parent && event.data == "report") {
window.parent.postMessage(JSON.stringify({"type": "child-five-report", "isActive": navigator.userActivation.isActive,
"hasBeenActive": navigator.userActivation.hasBeenActive}), "*");
}
});
</script>
</body>
......@@ -5,7 +5,7 @@
"hasBeenActive": navigator.userActivation.hasBeenActive}), "*");
window.addEventListener("message", event => {
if (event.source === window.parent && event.data == "transfer_user_activation") {
if (event.source === window.parent && event.data == "report") {
window.parent.postMessage(JSON.stringify({"type": "child-four-report", "isActive": navigator.userActivation.isActive,
"hasBeenActive": navigator.userActivation.hasBeenActive}), "*");
}
......
<!DOCTYPE html>
<body style="background: red;">
<body style="background: lightgrey;">
<script>
window.parent.postMessage(JSON.stringify({"type": "child-two-loaded", "isActive": navigator.userActivation.isActive,
"hasBeenActive": navigator.userActivation.hasBeenActive}), "*");
window.parent.postMessage(JSON.stringify({"type": "child-two-loaded", "isActive": navigator.userActivation.isActive,
"hasBeenActive": navigator.userActivation.hasBeenActive}), "*");
window.addEventListener("message", event => {
if (event.source === window.parent && event.data == "report") {
window.parent.postMessage(JSON.stringify({"type": "child-two-report", "isActive": navigator.userActivation.isActive,
"hasBeenActive": navigator.userActivation.hasBeenActive}), "*");
}
});
</script>
</body>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment