Standardizing�User Activation behavior
Mustaq Ahmed, Domenic Denicola
{mustaq,domenic}@chromium.org
TPAC, 18 Sep 2019
Overview
Goals:
What is “User Activation”?
User Activation in the Web today
A first look at spec vs reality
Full spreadsheet
Too vague and misleading
...
#yes
Let’s look at window.open
Events allowing popups
expiry
through setTimeout
through Promise
Through postMessage
Consumes?
in click handler
Based on a 2017 comparison
Current spec
Idea: “triggered by user activation”
// Not allowed:
body.onload = () => window.open();
// Allowed:
body.onclick = () => window.open();
// Allowed even with arbitrary "chaining":
body.onclick => setTimeout => window.open()
body.onclick => setTimeout => setTimeout … => window.open()
body.onclick => setTimeOut => setTimeout => Promise … => window.open()
Problems with current spec
setTimeout
popup
setTimeout
popup
setTimeout
popup
click
setTimeout
popup
The Web is broken
Chrome’s user activation changes
Fixing existing impl was not an option...
… so we started from scratch
All about “User Activation v2”
Immediately fixed�quite a few bugs,�upto 6+ years old!
For web devs: consistency across the board
// Child frame code:
someButton.addEventListener("click", () => {
parent.postMessage("hi_there", parent_origin);
parent.postMessage("open_popup", parent_origin);
});
// Parent frame code:
window.addEventListener("message", (e) => {
if (e.data === "open_popup") window.open("...");
});
Similar for any “chaining”: setTimeout, Promise, etc.
Proposed spec changes
Summary of our spec proposal
Pull request. Spec issue. Spec explainer
Interop is our ultimate goal
Seeking commitments from other browser.
Comments received so far:
Comment #1: Scope of the PR
User Activation
Permissions
<input type=...>
Higher level dependency
window.open
autoplay
media.play
Vibration
Clipboard
WebShare
WebUSB
WebBluetooth
Related bigger picture:�Web capability guards
Comment #2: Testing
Challenges:
We added these tests, try them in different browsers:
Comparison makes�the most sense�with “simple” APIs
Comment #3: Events defining user activation
Not covered by this PR:� doesn’t make sense w/o a clear model
See our plan in the next slide.
Planned sequence of changes
(Updated based on feedback received at the TPAC 2019 session)