diff --git a/third_party/blink/web_tests/external/wpt/html/user-activation/activation-trigger-click.html b/third_party/blink/web_tests/external/wpt/html/user-activation/activation-trigger-click.html new file mode 100644 index 00000000000000..abf685f9220e33 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/html/user-activation/activation-trigger-click.html @@ -0,0 +1,25 @@ + + + + + + + + + + +

Test for click activation trigger

+

Tests that a popup is allowed with user activation from a click event.

+
    +
  1. Click anywhere in the document. +
+ + + diff --git a/third_party/blink/web_tests/external/wpt/html/user-activation/activation-trigger-keypress.html b/third_party/blink/web_tests/external/wpt/html/user-activation/activation-trigger-keypress.html new file mode 100644 index 00000000000000..cf3816fd95e9b6 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/html/user-activation/activation-trigger-keypress.html @@ -0,0 +1,36 @@ + + + + + + + + + + +

Test for keypress activation trigger

+

Tests that a popup is allowed with user activation from a keypress event.

+ +
    +
  1. Press ENTER key. +
+ + + diff --git a/third_party/blink/web_tests/external/wpt/html/user-activation/basic.html b/third_party/blink/web_tests/external/wpt/html/user-activation/basic.html deleted file mode 100644 index fe8cebc1089e6a..00000000000000 --- a/third_party/blink/web_tests/external/wpt/html/user-activation/basic.html +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - -

Basic user activation test

-

Tests that a popup is allowed with user activation.

-
    -
  1. Click anywhere in the document. -
- - - diff --git a/third_party/blink/web_tests/external/wpt/html/user-activation/resources/utils.js b/third_party/blink/web_tests/external/wpt/html/user-activation/resources/utils.js index 06bf0183283809..f4ff426825612c 100644 --- a/third_party/blink/web_tests/external/wpt/html/user-activation/resources/utils.js +++ b/third_party/blink/web_tests/external/wpt/html/user-activation/resources/utils.js @@ -7,3 +7,27 @@ function delayByFrames(f, num_frames) { } recurse(num_frames); } + +// Returns a Promise which is resolved with the event object when the event is +// fired. +function getEvent(eventType) { + return new Promise(resolve => { + document.body.addEventListener(eventType, e => resolve(e), {once: true}); + }); +} + + +// Returns a Promise which is resolved with a "true" iff transient activation +// was available and successfully consumed. +// +// This function relies on Fullscreen API to check/consume user activation +// state. +async function consumeTransientActivation() { + try { + await document.body.requestFullscreen(); + await document.exitFullscreen(); + return true; + } catch(e) { + return false; + } +}