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

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/+/2110685Reviewed-by: default avatarNavid Zolghadr <nzolghadr@chromium.org>
Commit-Queue: Mustaq Ahmed <mustaq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#754529}
parent e7ed61af
......@@ -94,7 +94,8 @@ crbug.com/970285 external/wpt/forced-high-contrast-colors-mode/forced-colors-mod
crbug.com/852645 external/wpt/fullscreen/api/element-request-fullscreen-two-iframes-manual.html [ Timeout ]
crbug.com/982194 external/wpt/html/dom/elements/requirements-relating-to-bidirctional-algorithm-formatting-characters/dir-isolation-005c.html [ Failure ]
crbug.com/982194 external/wpt/html/rendering/non-replaced-elements/the-fieldset-and-legend-elements/fieldset-vertical.html [ Failure ]
crbug.com/736415 external/wpt/html/user-activation/activation-api-iframe.tentative.html [ Failure ]
crbug.com/736415 external/wpt/html/user-activation/navigation-state-reset-crossorigin.sub.tentative.html [ Failure ]
crbug.com/736415 external/wpt/html/user-activation/navigation-state-reset-sameorigin.tentative.html [ Failure ]
crbug.com/626703 external/wpt/infrastructure/testdriver/actions/eventOrder.html [ Timeout ]
crbug.com/982194 external/wpt/intersection-observe/v2/scaled-target.html [ Failure ]
crbug.com/982194 external/wpt/pointerevents/extension/pointerevent_touch-action-pan-down-css_touch.html [ Timeout ]
......
......@@ -5220,7 +5220,8 @@ crbug.com/854910 [ Mac ] virtual/scroll_customization/fast/scroll-behavior/smoot
crbug.com/855816 [ Win ] virtual/stable/http/tests/navigation/rename-subframe-goback.html [ Pass Timeout ]
# User Activation
crbug.com/736415 external/wpt/html/user-activation/activation-api-iframe.tentative.html [ Failure ]
crbug.com/736415 external/wpt/html/user-activation/navigation-state-reset-crossorigin.sub.tentative.html [ Failure ]
crbug.com/736415 external/wpt/html/user-activation/navigation-state-reset-sameorigin.tentative.html [ Failure ]
# Sheriff 2018-07-05
crbug.com/860731 fast/scroll-snap/animate-fling-to-snap-points.html [ Failure Pass ]
......
......@@ -673,8 +673,8 @@ external/wpt/html/semantics/scripting-1/the-script-element/module/dynamic-import
external/wpt/html/semantics/scripting-1/the-script-element/module/dynamic-import/string-compilation-base-url-inline-classic.html [ Failure Pass ] # wpt_subtest_failure
external/wpt/html/semantics/scripting-1/the-script-element/module/dynamic-import/string-compilation-base-url-inline-module.html [ Failure Pass ] # wpt_subtest_failure
external/wpt/html/semantics/scripting-1/the-script-element/module/module-in-xhtml.xhtml [ Failure Pass ] # wpt_subtest_failure
external/wpt/html/user-activation/activation-api-iframe.tenative.html [ Failure Pass ] # wpt_subtest_failure
external/wpt/html/user-activation/activation-api-iframe.tentative.html [ Pass Failure ] # wpt_subtest_failure
external/wpt/html/user-activation/navigation-state-reset-crossorigin.sub.tentative.html [ Failure ]
external/wpt/html/user-activation/navigation-state-reset-sameorigin.tentative.html [ Failure ]
external/wpt/html/user-activation/activation-transfer-cross-origin-with-click-two-child-frames.sub.tentative.html [ Failure Pass ] # wpt_subtest_failure
external/wpt/html/user-activation/activation-transfer-cross-origin-with-click.sub.tentative.html [ Failure Pass ] # wpt_subtest_failure
external/wpt/html/user-activation/activation-transfer-with-click.tentative.html [ Failure Pass ] # wpt_subtest_failure
......
<!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>
<!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>
<!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>
<!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>
<!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>
<!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>
<!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>
<!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>
......@@ -11,42 +11,43 @@
<script src="/resources/testdriver-vendor.js"></script>
</head>
<body>
<h1>Clicking in iframe has activation state in child</h1>
<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="200"
<iframe id="child" width="200" height="50"
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();
}
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();
}
}));
}, "Values adjust on activity");
}, "Post-navigation state reset.");
</script>
</body>
</html>
<!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>
<!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>
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