From c8bccf0319b865eea3070c30ebeac1d0e80d1cdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Sun, 20 Nov 2022 16:05:53 +0000 Subject: [PATCH] Bug 1799794 [wpt PR 36881] - User activation: refactor to support WebKit infrastructure, a=testonly Automatic update from web-platform-tests User activation: refactor to support WebKit infrastructure (#36881) -- wpt-commits: c82e31405103a43448c21161a1e4305ef94bbdfd wpt-pr: 36881 --- .../activation-trigger-keyboard-enter.html | 7 +- .../activation-trigger-keyboard-escape.html | 7 +- .../activation-trigger-mouse-left.html | 7 +- .../activation-trigger-mouse-right.html | 4 +- .../activation-trigger-pointerevent.html | 4 +- .../consumption-crossorigin.sub.html | 33 ++++--- .../consumption-sameorigin.html | 30 ++++-- .../html/user-activation/detached-iframe.html | 2 +- ...api-iframe-cross-origin.sub.tentative.html | 4 +- ...avigation-state-reset-crossorigin.sub.html | 9 +- .../navigation-state-reset-sameorigin.html | 99 +++++++++++-------- .../propagation-crossorigin.sub.html | 25 +++-- .../propagation-sameorigin.html | 24 +++-- .../consumption-crossorigin-child.sub.html | 2 +- .../propagation-crossorigin-child.sub.html | 2 +- .../user-activation-interface.html | 4 +- 16 files changed, 168 insertions(+), 95 deletions(-) diff --git a/testing/web-platform/tests/html/user-activation/activation-trigger-keyboard-enter.html b/testing/web-platform/tests/html/user-activation/activation-trigger-keyboard-enter.html index 4c1b31c50bd0d..be32d999b1a65 100644 --- a/testing/web-platform/tests/html/user-activation/activation-trigger-keyboard-enter.html +++ b/testing/web-platform/tests/html/user-activation/activation-trigger-keyboard-enter.html @@ -8,7 +8,7 @@ - +

Test for keyboard activation trigger for ENTER key

Tests user activation from a ENTER keyboard event.

@@ -16,14 +16,16 @@

Test for keyboard activation trigger for ENTER key

  • Press ENTER key. diff --git a/testing/web-platform/tests/html/user-activation/activation-trigger-keyboard-escape.html b/testing/web-platform/tests/html/user-activation/activation-trigger-keyboard-escape.html index 01cb27d7b5f09..82c94d84c2a95 100644 --- a/testing/web-platform/tests/html/user-activation/activation-trigger-keyboard-escape.html +++ b/testing/web-platform/tests/html/user-activation/activation-trigger-keyboard-escape.html @@ -8,7 +8,7 @@ - +

    Test for keyboard activation trigger for ESCAPE key

    Tests missing user activation from a ESCAPE keyboard event.

    @@ -16,13 +16,15 @@

    Test for keyboard activation trigger for ESCAPE key

  • Press ESCAPE key. diff --git a/testing/web-platform/tests/html/user-activation/activation-trigger-mouse-left.html b/testing/web-platform/tests/html/user-activation/activation-trigger-mouse-left.html index 51ad49a44ebdf..75a248c4259b5 100644 --- a/testing/web-platform/tests/html/user-activation/activation-trigger-mouse-left.html +++ b/testing/web-platform/tests/html/user-activation/activation-trigger-mouse-left.html @@ -8,20 +8,22 @@ - +

    Test for click activation trigger

    Tests user activation from a mouse click.

    1. Click anywhere in the document.
    diff --git a/testing/web-platform/tests/html/user-activation/activation-trigger-mouse-right.html b/testing/web-platform/tests/html/user-activation/activation-trigger-mouse-right.html index 1e9f839df3150..f98a54fe23810 100644 --- a/testing/web-platform/tests/html/user-activation/activation-trigger-mouse-right.html +++ b/testing/web-platform/tests/html/user-activation/activation-trigger-mouse-right.html @@ -9,13 +9,14 @@ - +

    Test for right-click activation trigger

    Tests user activation from a mouse right-click.

    1. Right-click anywhere in the document.
    diff --git a/testing/web-platform/tests/html/user-activation/activation-trigger-pointerevent.html b/testing/web-platform/tests/html/user-activation/activation-trigger-pointerevent.html index 49870936084f5..5d3eedb925e55 100644 --- a/testing/web-platform/tests/html/user-activation/activation-trigger-pointerevent.html +++ b/testing/web-platform/tests/html/user-activation/activation-trigger-pointerevent.html @@ -12,13 +12,14 @@ - +

    Test for pointerevent click activation trigger

    Tests user activation from a pointer click.

    1. Click anywhere in the document.
    diff --git a/testing/web-platform/tests/html/user-activation/consumption-crossorigin.sub.html b/testing/web-platform/tests/html/user-activation/consumption-crossorigin.sub.html index d84051cc93039..fbc2d25148376 100644 --- a/testing/web-platform/tests/html/user-activation/consumption-crossorigin.sub.html +++ b/testing/web-platform/tests/html/user-activation/consumption-crossorigin.sub.html @@ -44,6 +44,10 @@ } window.addEventListener("message", event => { + + // Test driver can send messages too... + if (typeof event.data !== "string") return; + var msg = JSON.parse(event.data); if (msg.type == 'child-one-loaded') { @@ -65,8 +69,8 @@ test_driver.click(document.getElementById("child-xo")); } else if (msg.type == 'child-one-report') { test(() => { - assert_false(msg.isActive); - assert_true(msg.hasBeenActive); + assert_false(msg.isActive, "Child1 frame isActive"); + assert_true(msg.hasBeenActive, "Child1 frame hasBeenActive"); }, "Child1 frame final state"); } else if (msg.type == 'child-crossorigin-report') { // This msg was triggered by a user click followed by a window.open(). @@ -81,8 +85,8 @@ frames[1].frames[0].postMessage(ask_report, "*"); } else if (msg.type == 'child-two-report') { test(() => { - assert_false(msg.isActive); - assert_false(msg.hasBeenActive); + assert_false(msg.isActive, "isActive"); + assert_false(msg.hasBeenActive, "hasBeenActive"); }, "Grand child frame final state"); } @@ -95,20 +99,27 @@ finishReportPhase(); } }); + async function createIframes() { + const child1 = document.createElement("iframe"); + child1.src = "http://{{hosts[alt][]}}:{{ports[http][0]}}/html/user-activation/resources/child-one.html"; + child1.id = "child1"; + await new Promise((resolve) => { + child1.onload = resolve; + document.body.appendChild(child1); + }); + const childXO = document.createElement("iframe"); + childXO.id = "child-xo"; + childXO.src = "http://{{hosts[alt][]}}:{{ports[http][1]}}/html/user-activation/resources/consumption-crossorigin-child.sub.html"; + document.body.appendChild(childXO); + } - +

    User activation consumption across cross-origin frame boundary

    Tests that user activation consumption resets the transient states in all cross-origin frames.

    1. Click anywhere on the yellow area.
    2. Click anywhere on the green area (child frame).
    - - diff --git a/testing/web-platform/tests/html/user-activation/consumption-sameorigin.html b/testing/web-platform/tests/html/user-activation/consumption-sameorigin.html index 11dafea1646f9..46a328beebc94 100644 --- a/testing/web-platform/tests/html/user-activation/consumption-sameorigin.html +++ b/testing/web-platform/tests/html/user-activation/consumption-sameorigin.html @@ -26,7 +26,7 @@ assert_false(navigator.userActivation.hasBeenActive); }, "Parent frame initial state"); - test_driver.click(document.getElementById("child-so")); + return test_driver.click(document.getElementById("child-so")); } function finishReportPhase() { @@ -40,7 +40,10 @@ consumption_test.done(); } - window.addEventListener("message", event => { + window.addEventListener("message", async event => { + // Test driver can send messages too... + if (typeof event.data !== "string") return; + var msg = JSON.parse(event.data); if (msg.type == 'child-one-loaded') { @@ -84,25 +87,32 @@ // Phase switching. if (msg.type.endsWith("-loaded")) { if (--num_children_to_load == 0) - finishLoadPhase(); + await finishLoadPhase(); } else if (msg.type.endsWith("-report")) { if (--num_children_to_report == 0) finishReportPhase(); } }); + async function createIframes() { + const child1 = document.createElement("iframe"); + child1.src = "resources/child-one.html"; + child1.id = "child1"; + await new Promise((resolve) => { + child1.onload = resolve; + document.body.appendChild(child1); + }); + const childSO = document.createElement("iframe"); + childSO.id = "child-so"; + childSO.src = "resources/consumption-sameorigin-child.html"; + document.body.appendChild(childSO); + } - +

    User activation consumption across same-origin frame boundary

    Tests that user activation consumption resets the transient states in all same-origin frames.

    1. Click anywhere on the green area (child frame).
    - - diff --git a/testing/web-platform/tests/html/user-activation/detached-iframe.html b/testing/web-platform/tests/html/user-activation/detached-iframe.html index 7ef39f723d1c9..af3d23072b4c9 100644 --- a/testing/web-platform/tests/html/user-activation/detached-iframe.html +++ b/testing/web-platform/tests/html/user-activation/detached-iframe.html @@ -42,6 +42,6 @@ assert_equals(iframe.contentWindow, null, "No more global"); assert_true(userActivation.isActive, "isActive"); assert_true(userActivation.hasBeenActive, "hasBeenActive"); - }, "navigator.userActivation retains state even if browsing context is destroyed"); + }, "navigator.userActivation retains state even if global is removed"); diff --git a/testing/web-platform/tests/html/user-activation/message-event-activation-api-iframe-cross-origin.sub.tentative.html b/testing/web-platform/tests/html/user-activation/message-event-activation-api-iframe-cross-origin.sub.tentative.html index cbb7285091068..2a16f4549678c 100644 --- a/testing/web-platform/tests/html/user-activation/message-event-activation-api-iframe-cross-origin.sub.tentative.html +++ b/testing/web-platform/tests/html/user-activation/message-event-activation-api-iframe-cross-origin.sub.tentative.html @@ -15,12 +15,12 @@

    Clicking in iframe has activation state in child via MessageEvent

    1. Click inside the red area.
    - - - - - - -

    Post-navigation activation state in child

    -

    Tests that navigating a same-origin child frame resets its activation states.

    -
      -
    1. Click inside the yellow area. -
    - - + + + + + +

    Post-navigation activation state in child

    +

    + Tests that navigating a same-origin child frame resets its activation + states. +

    +
      +
    1. Click inside the yellow area.
    2. +
    - 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); + + - + assert_true(navigator.userActivation.isActive); + assert_true(navigator.userActivation.hasBeenActive); + assert_true(child1Data.isActive); + assert_true(child1Data.hasBeenActive); + + child.src = "./resources/child-two.html"; + + const child2Data = await message("child-two-loaded"); + + assert_true(navigator.userActivation.isActive); + assert_true(navigator.userActivation.hasBeenActive); + assert_false(child2Data.isActive); + assert_false(child2Data.hasBeenActive); + }, "Post-navigation state reset."); + + diff --git a/testing/web-platform/tests/html/user-activation/propagation-crossorigin.sub.html b/testing/web-platform/tests/html/user-activation/propagation-crossorigin.sub.html index 5f3bb699281e1..d317764036f6d 100644 --- a/testing/web-platform/tests/html/user-activation/propagation-crossorigin.sub.html +++ b/testing/web-platform/tests/html/user-activation/propagation-crossorigin.sub.html @@ -43,6 +43,9 @@ } window.addEventListener("message", event => { + // Test driver can send messages too... + if (typeof event.data !== "string") return; + var msg = JSON.parse(event.data); if (msg.type == 'child-one-loaded') { @@ -92,19 +95,27 @@ finishReportPhase(); } }); + async function createIframes() { + const child1 = document.createElement("iframe"); + child1.src = "http://{{hosts[alt][]}}:{{ports[http][0]}}/html/user-activation/resources/child-one.html"; + child1.id = "child1"; + document.body.appendChild(child1); + await new Promise((resolve) => { + child1.onload = resolve; + document.body.appendChild(child1); + }); + const childXO = document.createElement("iframe"); + childXO.id = "child-xo"; + childXO.src = "http://{{hosts[alt][]}}:{{ports[http][1]}}/html/user-activation/resources/propagation-crossorigin-child.sub.html"; + document.body.appendChild(childXO); + } - +

    User activation propagation across cross-origin frame boundary

    Tests that user activation does not propagate across cross-origin frame boundary.

    1. Click anywhere on the green area (child frame).
    - - diff --git a/testing/web-platform/tests/html/user-activation/propagation-sameorigin.html b/testing/web-platform/tests/html/user-activation/propagation-sameorigin.html index 112563fce7514..61debbf948a3e 100644 --- a/testing/web-platform/tests/html/user-activation/propagation-sameorigin.html +++ b/testing/web-platform/tests/html/user-activation/propagation-sameorigin.html @@ -41,6 +41,9 @@ } window.addEventListener("message", event => { + // Test driver can send messages too... + if (typeof event.data !== "string") return; + var msg = JSON.parse(event.data); if (msg.type == 'child-one-loaded') { @@ -90,19 +93,26 @@ finishReportPhase(); } }); + async function createIframes() { + const child1 = document.createElement("iframe"); + child1.src = "resources/child-one.html"; + child1.id = "child1"; + await new Promise((resolve) => { + child1.onload = resolve; + document.body.appendChild(child1); + }); + const childSO = document.createElement("iframe"); + childSO.id = "child-so"; + childSO.src = "resources/propagation-sameorigin-child.html"; + document.body.appendChild(childSO); + } - +

    User activation propagation across same-origin frame boundary

    Tests that user activation propagates across same-origin frame boundary.

    1. Click anywhere on the green area (child frame).
    - - diff --git a/testing/web-platform/tests/html/user-activation/resources/consumption-crossorigin-child.sub.html b/testing/web-platform/tests/html/user-activation/resources/consumption-crossorigin-child.sub.html index c9f37ac8efd90..3ab469fe611bf 100644 --- a/testing/web-platform/tests/html/user-activation/resources/consumption-crossorigin-child.sub.html +++ b/testing/web-platform/tests/html/user-activation/resources/consumption-crossorigin-child.sub.html @@ -23,7 +23,7 @@
    Cross-origin child frame
    diff --git a/testing/web-platform/tests/html/user-activation/resources/propagation-crossorigin-child.sub.html b/testing/web-platform/tests/html/user-activation/resources/propagation-crossorigin-child.sub.html index 3cdd6886da2a8..ec465bf4acbbc 100644 --- a/testing/web-platform/tests/html/user-activation/resources/propagation-crossorigin-child.sub.html +++ b/testing/web-platform/tests/html/user-activation/resources/propagation-crossorigin-child.sub.html @@ -21,7 +21,7 @@
    Cross-origin child frame
    diff --git a/testing/web-platform/tests/html/user-activation/user-activation-interface.html b/testing/web-platform/tests/html/user-activation/user-activation-interface.html index cd808e010d369..8ece08f11d68b 100644 --- a/testing/web-platform/tests/html/user-activation/user-activation-interface.html +++ b/testing/web-platform/tests/html/user-activation/user-activation-interface.html @@ -7,13 +7,14 @@ - +

    Basic test for navigator.userActivation interface

    Tests that navigator.userActivation shows user activation states.

    1. Click anywhere in the document.