mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-20 00:35:44 +00:00
Bug 1624692 [wpt PR 22423] - Isolate activation-gated APIs from user-activation WPTs., a=testonly
Automatic update from web-platform-tests Isolate activation-gated APIs from user-activation WPTs. This CL isolates activation-gated APIs from the tests because those API behavior may depend on other browser-defined things. Four specific changes done here are: - Isolate a basic activation test as non-tentative. - Replace an existing wpt with a chained setTimeout test. - Isolate tests for same/cross-origin consumption behavior. - Clarify tests for same/cross-origin navigation behavior. Change-Id: I0a7e6d87fc8ed088cd162bbaa8584e8ea7710239 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2110685 Reviewed-by: Navid Zolghadr <nzolghadr@chromium.org> Commit-Queue: Mustaq Ahmed <mustaq@chromium.org> Cr-Commit-Position: refs/heads/master@{#754529} -- wpt-commits: bb678e5e0eab0abc4ab46f42c2f8ef91e0cbf904 wpt-pr: 22423
This commit is contained in:
parent
96ae4574d6
commit
b4723c0329
@ -1,34 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<!--
|
||||
Tentative due to:
|
||||
https://github.com/whatwg/html/issues/1983
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/resources/testdriver.js"></script>
|
||||
<script src="/resources/testdriver-vendor.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Clicking on document sets user activation</h1>
|
||||
<p>Click anywhere in the document.</p>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
assert_false(navigator.userActivation.hasBeenActive);
|
||||
assert_false(navigator.userActivation.isActive);
|
||||
window.addEventListener("click", t.step_func_done(event => {
|
||||
assert_true(navigator.userActivation.hasBeenActive);
|
||||
assert_true(navigator.userActivation.isActive);
|
||||
|
||||
// Opening a window should consume the activation.
|
||||
var win = window.open('404.html');
|
||||
win.close();
|
||||
assert_true(navigator.userActivation.hasBeenActive);
|
||||
assert_false(navigator.userActivation.isActive);
|
||||
}));
|
||||
test_driver.click(document.body);
|
||||
}, "Values adjust on activity");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,58 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<!--
|
||||
Tentative due to:
|
||||
https://github.com/whatwg/html/issues/1983
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/resources/testdriver.js"></script>
|
||||
<script src="/resources/testdriver-vendor.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Clicking in parent frame does not propagate state to child</h1>
|
||||
<ol id="instructions">
|
||||
<li>Click this instruction text.
|
||||
</ol>
|
||||
<iframe id="child" width="200" height="200"
|
||||
src="resources/child-one.html">
|
||||
</iframe>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
var child = document.getElementById("child");
|
||||
assert_false(navigator.userActivation.isActive);
|
||||
assert_false(navigator.userActivation.hasBeenActive);
|
||||
window.addEventListener("message", t.step_func(event => {
|
||||
var msg = JSON.parse(event.data);
|
||||
if (msg.type == 'child-one-loaded') {
|
||||
// Child's states should be false after load.
|
||||
assert_false(msg.isActive);
|
||||
assert_false(msg.hasBeenActive);
|
||||
|
||||
// Click in parent document.
|
||||
test_driver.click(document.getElementById('instructions'));
|
||||
} else if (msg.type == 'child-one-report') {
|
||||
// Only the transient state in child should be false after consumption below.
|
||||
assert_false(msg.isActive);
|
||||
assert_true(msg.hasBeenActive);
|
||||
t.done();
|
||||
}
|
||||
}));
|
||||
window.addEventListener("click", t.step_func(event => {
|
||||
assert_true(navigator.userActivation.isActive);
|
||||
assert_true(navigator.userActivation.hasBeenActive);
|
||||
|
||||
// Opening a window should consume the activation.
|
||||
var win = window.open('404.html');
|
||||
win.close();
|
||||
assert_false(navigator.userActivation.isActive);
|
||||
assert_true(navigator.userActivation.hasBeenActive);
|
||||
|
||||
// Ask child to report its state.
|
||||
child.contentWindow.postMessage(JSON.stringify({"type": "report"}), '*');
|
||||
}));
|
||||
}, "Values adjust on activity");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,52 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<!--
|
||||
Tentative due to:
|
||||
https://github.com/whatwg/html/issues/1983
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/resources/testdriver.js"></script>
|
||||
<script src="/resources/testdriver-vendor.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Clicking in iframe has activation state in child</h1>
|
||||
<ol id="instructions">
|
||||
<li>Click inside the yellow area.
|
||||
</ol>
|
||||
<iframe id="child" width="200" height="200"
|
||||
src="resources/child-one.html">
|
||||
</iframe>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
var child = document.getElementById("child");
|
||||
assert_false(navigator.userActivation.isActive);
|
||||
assert_false(navigator.userActivation.hasBeenActive);
|
||||
window.addEventListener("message", t.step_func(event => {
|
||||
var msg = JSON.parse(event.data);
|
||||
if (msg.type == 'child-one-loaded') {
|
||||
// values have false after load
|
||||
assert_false(msg.isActive);
|
||||
assert_false(msg.hasBeenActive);
|
||||
test_driver.click(child);
|
||||
} else if (msg.type == 'child-one-clicked') {
|
||||
// values have activation state on click
|
||||
assert_true(navigator.userActivation.isActive);
|
||||
assert_true(navigator.userActivation.hasBeenActive);
|
||||
assert_true(msg.isActive);
|
||||
assert_true(msg.hasBeenActive);
|
||||
child.src = "resources/child-two.html";
|
||||
} else if (msg.type == 'child-two-loaded') {
|
||||
// values are reset after navigation
|
||||
assert_true(navigator.userActivation.isActive);
|
||||
assert_true(navigator.userActivation.hasBeenActive);
|
||||
assert_false(msg.isActive);
|
||||
assert_false(msg.hasBeenActive);
|
||||
t.done();
|
||||
}
|
||||
}));
|
||||
}, "Values adjust on activity");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,36 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<!--
|
||||
Tentative due to:
|
||||
https://github.com/whatwg/html/issues/1983
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/resources/testdriver.js"></script>
|
||||
<script src="/resources/testdriver-vendor.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Clicking on document sets user activation even after setTimeout</h1>
|
||||
<p>Click anywhere in the document.</p>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
assert_false(navigator.userActivation.hasBeenActive);
|
||||
assert_false(navigator.userActivation.isActive);
|
||||
window.addEventListener("click", event => {
|
||||
t.step_timeout(() => {
|
||||
assert_true(navigator.userActivation.hasBeenActive);
|
||||
assert_true(navigator.userActivation.isActive);
|
||||
|
||||
// Opening a window should consume the activation.
|
||||
window.open('404.html');
|
||||
assert_true(navigator.userActivation.hasBeenActive);
|
||||
assert_false(navigator.userActivation.isActive);
|
||||
t.done();
|
||||
}, 0);
|
||||
});
|
||||
test_driver.click(document.body);
|
||||
}, "Values adjust on activity");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
30
testing/web-platform/tests/html/user-activation/basic.html
Normal file
30
testing/web-platform/tests/html/user-activation/basic.html
Normal file
@ -0,0 +1,30 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/resources/testdriver.js"></script>
|
||||
<script src="/resources/testdriver-vendor.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Basic user activation test</h1>
|
||||
<p>Tests that a popup is allowed with user activation.</p>
|
||||
<ol id="instructions">
|
||||
<li>Click anywhere in the document.
|
||||
</ol></body>
|
||||
<script>
|
||||
let test_w_click = async_test("Popup with click");
|
||||
|
||||
window.addEventListener("click", () => {
|
||||
test_w_click.step(() => {
|
||||
let win = window.open();
|
||||
assert_true(!!win);
|
||||
win.close();
|
||||
});
|
||||
test_w_click.done();
|
||||
});
|
||||
|
||||
test_driver.click(document.body);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,64 @@
|
||||
<!DOCTYPE html>
|
||||
<!--
|
||||
Tentative due to:
|
||||
https://github.com/whatwg/html/issues/1983
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/resources/testdriver.js"></script>
|
||||
<script src="/resources/testdriver-vendor.js"></script>
|
||||
<script>
|
||||
const max_call_depth = 3;
|
||||
let initial_async_tests = {};
|
||||
let final_async_tests = {};
|
||||
|
||||
function testInitialStates(depth) {
|
||||
assert_true(1 <= depth && depth <= max_call_depth);
|
||||
|
||||
initial_async_tests[depth].step_timeout(() => {
|
||||
assert_false(navigator.userActivation.isActive);
|
||||
assert_false(navigator.userActivation.hasBeenActive);
|
||||
initial_async_tests[depth].done();
|
||||
|
||||
if (depth < max_call_depth)
|
||||
testInitialStates(depth+1);
|
||||
}, 10);
|
||||
}
|
||||
|
||||
function testFinalStates(depth) {
|
||||
assert_true(1 <= depth && depth <= max_call_depth);
|
||||
|
||||
final_async_tests[depth].step_timeout(() => {
|
||||
assert_true(navigator.userActivation.isActive);
|
||||
assert_true(navigator.userActivation.hasBeenActive);
|
||||
final_async_tests[depth].done();
|
||||
|
||||
if (depth < max_call_depth)
|
||||
testFinalStates(depth+1);
|
||||
}, 10)
|
||||
}
|
||||
|
||||
function run() {
|
||||
for (let i = 1; i <= max_call_depth; i++) {
|
||||
initial_async_tests[i] = async_test("Call-depth=" + i + " initial state");
|
||||
final_async_tests[i] = async_test("Call-depth=" + i + " final state");
|
||||
}
|
||||
|
||||
testInitialStates(1);
|
||||
|
||||
window.addEventListener("click", event => {
|
||||
testFinalStates(1);
|
||||
});
|
||||
test_driver.click(document.body);
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body onload="run()">
|
||||
<h1>User activation state in chained setTimeout calls</h1>
|
||||
<p>Tests that user activation state is visible in arbitrary call depth of setTimeout.</p>
|
||||
<ol id="instructions">
|
||||
<li>Click anywhere in the document.
|
||||
</ol></body>
|
||||
</html>
|
@ -0,0 +1,131 @@
|
||||
<!DOCTYPE html>
|
||||
<!--
|
||||
Tentative due to:
|
||||
https://github.com/whatwg/html/issues/1983
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/resources/testdriver.js"></script>
|
||||
<script src="/resources/testdriver-vendor.js"></script>
|
||||
<script>
|
||||
// Frame layout:
|
||||
// top=origin0:this-file [
|
||||
// child1=origin1:child-one.html,
|
||||
// child-xo=origin2:consumption-crossorigin-child.html [
|
||||
// gchild=origin3:child-two.html
|
||||
// ]
|
||||
// ]
|
||||
let test_parent_initial = async_test("Parent frame initial state");
|
||||
let test_parent_final = async_test("Parent frame final state");
|
||||
|
||||
let test_child1_initial = async_test("Child1 frame initial state");
|
||||
let test_child1_final = async_test("Child1 frame final state");
|
||||
|
||||
let test_child_xo_initial = async_test("Child2 frame initial state");
|
||||
let test_child_xo_final = async_test("Child2 frame final state");
|
||||
|
||||
let test_gchild_initial = async_test("Grandchild frame initial state");
|
||||
let test_gchild_final = async_test("Grand child frame final state");
|
||||
|
||||
let num_children_to_load = 3;
|
||||
let num_children_to_report = 3;
|
||||
|
||||
function finishLoadPhase() {
|
||||
test_parent_initial.step(() => {
|
||||
assert_true(num_children_to_load == 0);
|
||||
assert_false(navigator.userActivation.isActive);
|
||||
assert_false(navigator.userActivation.hasBeenActive);
|
||||
});
|
||||
test_parent_initial.done();
|
||||
|
||||
test_driver.click(document.getElementById("child1"));
|
||||
// The click at "child-xo" happens after receiving "child-one-clicked" msg.
|
||||
}
|
||||
|
||||
function finishReportPhase() {
|
||||
test_parent_final.step(() => {
|
||||
assert_true(num_children_to_report == 0);
|
||||
assert_false(navigator.userActivation.isActive);
|
||||
assert_true(navigator.userActivation.hasBeenActive);
|
||||
});
|
||||
test_parent_final.done();
|
||||
// End of all tests.
|
||||
}
|
||||
|
||||
window.addEventListener("message", event => {
|
||||
var msg = JSON.parse(event.data);
|
||||
|
||||
if (msg.type == 'child-one-loaded') {
|
||||
test_child1_initial.step(() => {
|
||||
assert_false(msg.isActive);
|
||||
assert_false(msg.hasBeenActive);
|
||||
});
|
||||
test_child1_initial.done();
|
||||
} else if (msg.type == 'child-crossorigin-loaded') {
|
||||
test_child_xo_initial.step(() => {
|
||||
assert_false(msg.isActive);
|
||||
assert_false(msg.hasBeenActive);
|
||||
});
|
||||
test_child_xo_initial.done();
|
||||
} else if (msg.type == 'child-two-loaded') {
|
||||
test_gchild_initial.step(() => {
|
||||
assert_false(msg.isActive);
|
||||
assert_false(msg.hasBeenActive);
|
||||
});
|
||||
test_gchild_initial.done();
|
||||
} else if (msg.type == 'child-one-clicked') {
|
||||
test_driver.click(document.getElementById("child-xo"));
|
||||
} else if (msg.type == 'child-one-report') {
|
||||
test_child1_final.step(() => {
|
||||
assert_false(msg.isActive);
|
||||
assert_true(msg.hasBeenActive);
|
||||
});
|
||||
test_child1_final.done();
|
||||
} else if (msg.type == 'child-crossorigin-report') {
|
||||
// This msg was triggered by a user click followed by a window.open().
|
||||
test_child_xo_final.step(() => {
|
||||
assert_false(msg.isActive);
|
||||
assert_true(msg.hasBeenActive);
|
||||
});
|
||||
test_child_xo_final.done();
|
||||
|
||||
// Ask remaining frames to report states.
|
||||
let ask_report = JSON.stringify({"type": "report"});
|
||||
frames[0].postMessage(ask_report, "*");
|
||||
frames[1].frames[0].postMessage(ask_report, "*");
|
||||
} else if (msg.type == 'child-two-report') {
|
||||
test_gchild_final.step(() => {
|
||||
assert_false(msg.isActive);
|
||||
assert_false(msg.hasBeenActive);
|
||||
});
|
||||
test_gchild_final.done();
|
||||
}
|
||||
|
||||
// Phase switching.
|
||||
if (msg.type.endsWith("-loaded")) {
|
||||
if (--num_children_to_load == 0)
|
||||
finishLoadPhase();
|
||||
} else if (msg.type.endsWith("-report")) {
|
||||
if (--num_children_to_report == 0)
|
||||
finishReportPhase();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>User activation consumption across cross-origin frame boundary</h1>
|
||||
<p>Tests that user activation consumption resets the transient states in all cross-origin frames.</p>
|
||||
<ol id="instructions">
|
||||
<li>Click anywhere on the yellow area.
|
||||
<li>Click anywhere on the green area (child frame).
|
||||
</ol>
|
||||
<iframe id="child1" width="300px" height="40px"
|
||||
src="http://{{domains[www1]}}:{{ports[http][0]}}/html/user-activation/resources/child-one.html">
|
||||
</iframe>
|
||||
<iframe id="child-xo" width="300px" height="140px"
|
||||
src="http://{{domains[www2]}}:{{ports[http][0]}}/html/user-activation/resources/consumption-crossorigin-child.sub.html">
|
||||
</iframe>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,127 @@
|
||||
<!DOCTYPE html>
|
||||
<!--
|
||||
Tentative due to:
|
||||
https://github.com/whatwg/html/issues/1983
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/resources/testdriver.js"></script>
|
||||
<script src="/resources/testdriver-vendor.js"></script>
|
||||
<script>
|
||||
// Frame layout:
|
||||
// top=this-file [
|
||||
// child1=child-one.html,
|
||||
// child-so=consumption-sameorigin-child.html [
|
||||
// gchild=child-two.html
|
||||
// ]
|
||||
// ]
|
||||
let test_parent_initial = async_test("Parent frame initial state");
|
||||
let test_parent_final = async_test("Parent frame final state");
|
||||
|
||||
let test_child1_initial = async_test("Child1 frame initial state");
|
||||
let test_child1_final = async_test("Child1 frame final state");
|
||||
|
||||
let test_child_so_initial = async_test("Child2 frame initial state");
|
||||
let test_child_so_final = async_test("Child2 frame final state");
|
||||
|
||||
let test_gchild_initial = async_test("Grandchild frame initial state");
|
||||
let test_gchild_final = async_test("Grand child frame final state");
|
||||
|
||||
let num_children_to_load = 3;
|
||||
let num_children_to_report = 3;
|
||||
|
||||
function finishLoadPhase() {
|
||||
test_parent_initial.step(() => {
|
||||
assert_true(num_children_to_load == 0);
|
||||
assert_false(navigator.userActivation.isActive);
|
||||
assert_false(navigator.userActivation.hasBeenActive);
|
||||
});
|
||||
test_parent_initial.done();
|
||||
|
||||
test_driver.click(document.getElementById("child-so"));
|
||||
}
|
||||
|
||||
function finishReportPhase() {
|
||||
test_parent_final.step(() => {
|
||||
assert_true(num_children_to_report == 0);
|
||||
assert_false(navigator.userActivation.isActive);
|
||||
assert_true(navigator.userActivation.hasBeenActive);
|
||||
});
|
||||
test_parent_final.done();
|
||||
// End of all tests.
|
||||
}
|
||||
|
||||
window.addEventListener("message", event => {
|
||||
var msg = JSON.parse(event.data);
|
||||
|
||||
if (msg.type == 'child-one-loaded') {
|
||||
test_child1_initial.step(() => {
|
||||
assert_false(msg.isActive);
|
||||
assert_false(msg.hasBeenActive);
|
||||
});
|
||||
test_child1_initial.done();
|
||||
} else if (msg.type == 'child-sameorigin-loaded') {
|
||||
test_child_so_initial.step(() => {
|
||||
assert_false(msg.isActive);
|
||||
assert_false(msg.hasBeenActive);
|
||||
});
|
||||
test_child_so_initial.done();
|
||||
} else if (msg.type == 'child-two-loaded') {
|
||||
test_gchild_initial.step(() => {
|
||||
assert_false(msg.isActive);
|
||||
assert_false(msg.hasBeenActive);
|
||||
});
|
||||
test_gchild_initial.done();
|
||||
} else if (msg.type == 'child-one-report') {
|
||||
test_child1_final.step(() => {
|
||||
assert_false(msg.isActive);
|
||||
assert_true(msg.hasBeenActive);
|
||||
});
|
||||
test_child1_final.done();
|
||||
} else if (msg.type == 'child-sameorigin-report') {
|
||||
// This msg was triggered by a user click followed by a window.open().
|
||||
test_child_so_final.step(() => {
|
||||
assert_false(msg.isActive);
|
||||
assert_true(msg.hasBeenActive);
|
||||
});
|
||||
test_child_so_final.done();
|
||||
|
||||
// Ask remaining frames to report states.
|
||||
let ask_report = JSON.stringify({"type": "report"});
|
||||
frames[0].postMessage(ask_report, "*");
|
||||
frames[1].frames[0].postMessage(ask_report, "*");
|
||||
} else if (msg.type == 'child-two-report') {
|
||||
test_gchild_final.step(() => {
|
||||
assert_false(msg.isActive);
|
||||
assert_true(msg.hasBeenActive);
|
||||
});
|
||||
test_gchild_final.done();
|
||||
}
|
||||
|
||||
// Phase switching.
|
||||
if (msg.type.endsWith("-loaded")) {
|
||||
if (--num_children_to_load == 0)
|
||||
finishLoadPhase();
|
||||
} else if (msg.type.endsWith("-report")) {
|
||||
if (--num_children_to_report == 0)
|
||||
finishReportPhase();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>User activation consumption across same-origin frame boundary</h1>
|
||||
<p>Tests that user activation consumption resets the transient states in all same-origin frames.</p>
|
||||
<ol id="instructions">
|
||||
<li>Click anywhere on the green area (child frame).
|
||||
</ol>
|
||||
<iframe id="child1" width="300px" height="40px"
|
||||
src="resources/child-one.html">
|
||||
</iframe>
|
||||
<iframe id="child-so" width="300px" height="140px"
|
||||
src="resources/consumption-sameorigin-child.html">
|
||||
</iframe>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,53 @@
|
||||
<!DOCTYPE html>
|
||||
<!--
|
||||
Tentative due to:
|
||||
https://github.com/whatwg/html/issues/1983
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/resources/testdriver.js"></script>
|
||||
<script src="/resources/testdriver-vendor.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Post-navigation activation state in child</h1>
|
||||
<p>Tests that navigating a cross-origin child frame resets its activation states.</p>
|
||||
<ol id="instructions">
|
||||
<li>Click inside the yellow area.
|
||||
</ol>
|
||||
<iframe id="child" width="200" height="50"
|
||||
src="http://{{domains[www1]}}:{{ports[http][0]}}/html/user-activation/resources/child-one.html">
|
||||
</iframe>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
var child = document.getElementById("child");
|
||||
window.addEventListener("message", t.step_func(event => {
|
||||
var msg = JSON.parse(event.data);
|
||||
if (msg.type == 'child-one-loaded') {
|
||||
assert_false(navigator.userActivation.isActive);
|
||||
assert_false(navigator.userActivation.hasBeenActive);
|
||||
assert_false(msg.isActive);
|
||||
assert_false(msg.hasBeenActive);
|
||||
|
||||
test_driver.click(child);
|
||||
} else if (msg.type == 'child-one-clicked') {
|
||||
assert_true(navigator.userActivation.isActive);
|
||||
assert_true(navigator.userActivation.hasBeenActive);
|
||||
assert_true(msg.isActive);
|
||||
assert_true(msg.hasBeenActive);
|
||||
|
||||
child.src = "http://{{domains[www2]}}:{{ports[http][0]}}/html/user-activation/resources/child-two.html";
|
||||
} else if (msg.type == 'child-two-loaded') {
|
||||
assert_true(navigator.userActivation.isActive);
|
||||
assert_true(navigator.userActivation.hasBeenActive);
|
||||
assert_false(msg.isActive);
|
||||
assert_false(msg.hasBeenActive);
|
||||
|
||||
t.done();
|
||||
}
|
||||
}));
|
||||
}, "Post-navigation state reset.");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,53 @@
|
||||
<!DOCTYPE html>
|
||||
<!--
|
||||
Tentative due to:
|
||||
https://github.com/whatwg/html/issues/1983
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/resources/testdriver.js"></script>
|
||||
<script src="/resources/testdriver-vendor.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Post-navigation activation state in child</h1>
|
||||
<p>Tests that navigating a same-origin child frame resets its activation states.</p>
|
||||
<ol id="instructions">
|
||||
<li>Click inside the yellow area.
|
||||
</ol>
|
||||
<iframe id="child" width="200" height="50"
|
||||
src="resources/child-one.html">
|
||||
</iframe>
|
||||
<script>
|
||||
async_test(function(t) {
|
||||
var child = document.getElementById("child");
|
||||
window.addEventListener("message", t.step_func(event => {
|
||||
var msg = JSON.parse(event.data);
|
||||
if (msg.type == 'child-one-loaded') {
|
||||
assert_false(navigator.userActivation.isActive);
|
||||
assert_false(navigator.userActivation.hasBeenActive);
|
||||
assert_false(msg.isActive);
|
||||
assert_false(msg.hasBeenActive);
|
||||
|
||||
test_driver.click(child);
|
||||
} else if (msg.type == 'child-one-clicked') {
|
||||
assert_true(navigator.userActivation.isActive);
|
||||
assert_true(navigator.userActivation.hasBeenActive);
|
||||
assert_true(msg.isActive);
|
||||
assert_true(msg.hasBeenActive);
|
||||
|
||||
child.src = "resources/child-two.html";
|
||||
} else if (msg.type == 'child-two-loaded') {
|
||||
assert_true(navigator.userActivation.isActive);
|
||||
assert_true(navigator.userActivation.hasBeenActive);
|
||||
assert_false(msg.isActive);
|
||||
assert_false(msg.hasBeenActive);
|
||||
|
||||
t.done();
|
||||
}
|
||||
}));
|
||||
}, "Post-navigation state reset.");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,29 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<script>
|
||||
window.top.postMessage(JSON.stringify({
|
||||
"type": "child-crossorigin-loaded",
|
||||
"isActive": navigator.userActivation.isActive,
|
||||
"hasBeenActive": navigator.userActivation.hasBeenActive
|
||||
}), "*");
|
||||
|
||||
window.addEventListener("click", event => {
|
||||
window.open().close();
|
||||
|
||||
window.top.postMessage(JSON.stringify({
|
||||
"type": "child-crossorigin-report",
|
||||
"isActive": navigator.userActivation.isActive,
|
||||
"hasBeenActive": navigator.userActivation.hasBeenActive
|
||||
}), "*");
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body style="background: lightgreen;">
|
||||
<!-- The midpoint of this frame should be outside the grandchild frame. -->
|
||||
<div style="height: 75px;">Cross-origin child frame</div>
|
||||
<iframe id="child2" width="270px" height="30px"
|
||||
src="http://{{domains[www]}}:{{ports[http][0]}}/html/user-activation/resources/child-two.html">
|
||||
</iframe>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,29 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<script>
|
||||
window.top.postMessage(JSON.stringify({
|
||||
"type": "child-sameorigin-loaded",
|
||||
"isActive": navigator.userActivation.isActive,
|
||||
"hasBeenActive": navigator.userActivation.hasBeenActive
|
||||
}), "*");
|
||||
|
||||
window.addEventListener("click", event => {
|
||||
window.open().close();
|
||||
|
||||
window.top.postMessage(JSON.stringify({
|
||||
"type": "child-sameorigin-report",
|
||||
"isActive": navigator.userActivation.isActive,
|
||||
"hasBeenActive": navigator.userActivation.hasBeenActive
|
||||
}), "*");
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body style="background: lightgreen;">
|
||||
<!-- The midpoint of this frame should be outside the grandchild frame. -->
|
||||
<div style="height: 75px;">Same-origin child frame</div>
|
||||
<iframe id="child2" width="270px" height="30px"
|
||||
src="child-two.html">
|
||||
</iframe>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user