triggered by user activation

利用者活性化

[81] DOM API の中には () (よう) (しゃ) (かっ) (せい) () (user activation) が必要なものがいくつかあります。 利用者活性化とは、 利用者viewport 内の要素クリックするなど、 当該閲覧文脈に対して明確に操作する意思を示したことをいいます。

[82] 利用者活性化の制約は、ある種のブラクラのような利用者の操作を妨害する動作をスクリプト (の著者) が勝手に実行させることを防ぐものであります。 Webプラットフォームの草創期 (平成時代初期) にその危険性が知られるようになり、発見的な制約から徐々に整備が進んできました。 現在では HTML Standard によって挙動が詳細に定められています。

仕様書

文脈

[83] 利用者活性化の制約は、 viewport の枠を超えて画面表示に干渉するような操作や、 装置 (ハードウェア) の状態を変化させるような操作などに課されています。

[77] 利用者活性化は、 粘着性活性化過渡活性化の2つに大別されます。 両者の使い方によって、 利用者活性化に依存した API は3種類に分類されます。

活性化通知

[84] 利用者活性化は、 (Window) ごとに管理されます。 つまり利用者Webブラウザーのあるを操作しても、 他のには影響しません。 また、 利用者があるフレームを操作しても、 他のフレームに影響するとは限りません。

[85] 利用者によるクリックなどの操作は、 活性化通知につながります。

[40] Window は、 (さい) (しゅう) (かっ) (せい) () () (こく) (いん) (last activation timestamp) を持ちます。 これは、 最後の活性化通知を得た時刻を表しています。 DOMHighResTimeStamp 値の他に、 +∞-∞ となることがあります。 初期値は +∞ です。 >>39

[49] 閲覧文脈閲覧文脈における (かっ) (せい) () (つう) () (activation notification) は、 次のようにします。 >>39

  1. [51] 文書を、 閲覧文脈活性文書に設定します。
  2. [52] 閲覧文脈群を、 閲覧文脈閲覧文脈祖先閲覧文脈すべて、 文書list of descendant browsing contexts 中の閲覧文脈のうち、 その活性文書文書同じ起源であるものすべて、 を含むリストに設定します。
  3. [53] 窓群を、 閲覧文脈群中の各閲覧文脈WindowProxyWindowから構築したWindowリストに設定します。
  4. [54] 窓群の各について、順に
    1. [55] 最終活性化時刻印を、 現在高解像度時刻に設定します。

[50] 利用者エージェントは、 閲覧文脈閲覧文脈における user interaction に関する activation triggering input eventdispatch の前に、 閲覧文脈について活性化通知しなければなりません>>39

[56] activation triggering input event は、 次のすべてを満たすイベントイベントです。 >>39

[87] 装置からの入力を表すイベントでも、 mousemoveorientationchange のように利用者の明示的な操作を表すとはいえないものは含まれていません。
[88] 利用者エージェントが発生させるイベントが対象です。 スクリプトdispacthEvent を使っても効果はありません。

粘着性活性化

[43] Window (ねん) (ちゃく) (せい) (かっ) (せい) () (sticky activation) 状態であるか否かは、

最終活性化時刻印現在高解像度時刻

... であるか否かです。 >>39

[44] 粘着性活性化は、 利用者と interaction したことがあるかどうかを表しています。 初期状態ではになります (現在高解像度時刻+∞)。 が初めて活性化通知を得たときとなり、 再びとなることはありません。 >>39

[45] Web頁を開いたとき (または勝手に開かれたとき)、 利用者が何も操作していないのに、 勝手に意図せぬ動作をして利用者が困るのを防ぐため、 使われています。

過渡活性化

[46] Window () () (かっ) (せい) () (transient activation) 状態であるか否かは、

最終活性化時刻印現在高解像度時刻 < 最終活性化時刻印 + 過渡活性化時間長

... であるか否かです。 >>39

[47] 過渡活性化は、 利用者が最近と interaction したかどうかを表しています。 初期状態ではになります。 活性化通知を得たときとなり、 しばらくしてに戻ります。 >>39

[86] 過渡活性化からに変化するのは、 一定時間が経過した場合 (満期) と、 特定の API が呼び出された場合 (利用者活性化消費) の2通りがあります。


[41] () () (かっ) (せい) () () (かん) (ちょう) (transient activation duration) は、 利用者エージェントの定義する値です。 対象の API において利用者による活性化が利用可能な長さを表す定数です。 >>39

[42] この値は、高々数秒程度で、 利用者によるとの interaction と、 が当該 API を呼び出したこととの関係を知覚できる長さであることが期待されています。 >>39

[48] 過渡活性化状態が過渡活性化時間長の経過を以てとなることを、 (まん) () (ずみ) (expired) といいます。 >>39


[59] Window について () (よう) (しゃ) (かっ) (せい) () (しょう) () (consume user activation) は、 次のようにします。 >>39

  1. [61] 閲覧文脈null の場合、
    1. [62] ここで停止します。
  2. [63] を、 閲覧文脈最上位閲覧文脈に設定します。
  3. [70] 閲覧文脈群を、 活性文書list of the descendant browsing contextsに設定します。
  4. [71] を、 閲覧文脈群末尾に追加します。
  5. [72] 窓群を、 閲覧文脈群中の各閲覧文脈WindowProxyWindowから構築したWindowリストに設定します。
  6. [73] 窓群の各について、順に
    1. [74] 最終活性化時刻印+∞ない場合、
      1. [75] 最終活性化時刻印を、 -∞ に設定します。
[76] 仕様書アルゴリズム中の list of the descendant browsing contexts は毎回新しい複製が得られるようです。

[60] 活性化消費するAPIから呼び出されます。 >>39


[89] 過渡活性化は、 次の場面で参照されます。

[90] 過渡活性化状態用API

歴史

初期モデル

[1] Editorial: "allowed to show a popup" → "triggered by user activation" ( (domenic著, )) https://github.com/whatwg/html/commit/797f412eb78fd88bd5d0a1c098d17fbf1736c188

[2] Existing intervention: user gesture required for sensitive operations · Issue #12 · WICG/interventions ( ()) https://github.com/WICG/interventions/issues/12

[3] Allow requestFullscreen() to be called from an orientation change event (mounirlamouri著, ) https://github.com/whatwg/fullscreen/commit/e5e96a9da944babf0e246980559cd80a46a300ca

[11] 17041 – Setting location before the page is done loading shouldn't always be a replace load ( ()) https://www.w3.org/Bugs/Public/show_bug.cgi?id=17041

[12] Consider pointerup and touchend for "triggered by user activation" (NavidZ著, ) https://github.com/whatwg/html/commit/adafe995c6d4f5f6df0497a534d31e51043b6750

[30] Add allow-top-navigation-by-user-activation sandbox token (domenic著, ) https://github.com/whatwg/html/commit/8abd73ec3a56541e3f6486d3a593a8bcfd67295d

[33] Require user gesture to request notification permissions · Issue #49 · WICG/interventions () https://github.com/WICG/interventions/issues/49

[34] Need concept of "consuming" user activation · Issue #3122 · whatwg/html () https://github.com/whatwg/html/issues/3122

[35] Treat trusted contextmenu events as user activation (mustaqahmed著, ) https://github.com/whatwg/html/commit/51bd770cf58cdd761674df0f47c9f9dfc58c5310

[36] Treat trusted `contextmenu` events as user activation. by mustaqahmed · Pull Request #3659 · whatwg/html () https://github.com/whatwg/html/pull/3659

[37] Deprecations and removals in Chrome 69  |  Web  |  Google Developers () https://developers.google.com/web/updates/2018/09/chrome-70-deps-rems

user activation

[69] triggered by user activation (旧 allowed to show a popup) とは、次のいずれかの条件を満たすことをいいます >>68

[17] 時間制限は、例えばクリックから数秒後ならともかく、数時間後は相応しくない >>68 ことによります。

[29] buttonクリック時のポップアップは認められますが、 input の入力や select の変更では認められません。

[31] 他に、閲覧文脈外部で利用者の明示的な指示があった場合も含めるべきと思われます。

[32] 例えば利用者ブックマークから選択したブックマークレットwindow.open を実行した場合、ポップアップ窓が開かれるのが普通です。


[64] Location では、次のいずれかの条件を満たすと分岐します >>65。 (タスク以外の判定条件もあります。 Location 参照。)

[18] タスクは、自身がこの条件を満たしているかどうかの情報を保持しておく必要があります。 またイベントオブジェクト (の持つ情報の一部または全部) も必要かもしれません。 例えば window.open は、プラットフォームの慣習により、 Ctrl 押下時に新しい閲覧文脈を常に開く、といったような動作にできます。

[25] 実際には triggered by user activation の実装 (またはその呼び出し元の実装) は更に厳しく制限しているかもしれません。

[27] 例えば同じタスク内で多数の新しい最上位閲覧文脈を作成するのはブラクラであり、 拒否するべきと考えられます。

[26] 更に、タスクを超えた制約もあるかもしれません。

[28] 例えば setTimeout を使って短時間に別のタスクで多くの新しい最上位閲覧文脈を作成するのはブラクラであり、 拒否するべきと考えられます。

[19] triggered by user activation は、次の場面で使われます。

[13] engagement gesture でもイベントのリストが参照されています。

user orientation change

[10] triggered by a user generated orientation change とは、 現在走っているタスクprocess user orientation changeであることをいいます >>9

全画面の要求

[5] allowed to request fullscreen とは、

... のいずれかであることをいいます >>4

[8] これは、 requestFullscreen で参照されます。

令和元(2019)年改定モデル

[95] User Activation v2 in Chrome - Google ドキュメント, https://docs.google.com/document/d/1erpl1yqJlc1pH0QvVVmi1s3WzqQLsEXTLLh6VuYp228/edit

[99] User Activation v2 (UAv2) | user-activation-v2, , https://mustaqahmed.github.io/user-activation-v2/

[100] User Activation v2 browser-side - Google ドキュメント, https://docs.google.com/document/d/1XL3vCedkqL65ueaGVD-kfB5RnnrnTaxLc7kmU91oerg/edit

[38] Revamp the user activation model (mustaqahmed, , ) https://github.com/whatwg/html/commit/8f8c1f50158736b3cf16188377a0974a20367c8b

[91] Make "triggered by user activation" match browser behavior · Issue #1903 · whatwg/html () https://github.com/whatwg/html/issues/1903

[92] Events list that trigger "allowed to show a popup" seems too small · Issue #1358 · whatwg/html () https://github.com/whatwg/html/issues/1358

[93] pop-up blocker algorithm doesn't define behavior for touch · Issue #599 · whatwg/html () https://github.com/whatwg/html/issues/599

[94] Need concept of "consuming" user activation · Issue #3122 · whatwg/html () https://github.com/whatwg/html/issues/3122

[96] Existing Chrome APIs using user gestures - Google ドキュメント, https://docs.google.com/document/d/1mcxB5J_u370juJhSsmK0XQONG2CIE3mvu827O-Knw_Y/edit

[97] Some means to signal that a method requires user action to be called · Issue #479 · whatwg/webidl () https://github.com/whatwg/webidl/issues/479

[98] Activation-triggering events across browsers - Google スプレッドシート, https://docs.google.com/spreadsheets/d/1DGXjhQ6D3yZXIePOMo0dsd2agz0t5W7rYH1NwJ-QGJo/edit#gid=0

[101] Added a new section on User Activation v2. by mustaqahmed · Pull Request #3851 · whatwg/html · GitHub, https://github.com/whatwg/html/pull/3851

[108] User activation TPAC session summary - Google ドキュメント, https://docs.google.com/document/d/1gHxQMdXGX4UjjoPXi0c1vhwYregQzWNEHqgbydopCoo/edit#

[102] User Activation @BlinkOn10 - Google スライド, https://docs.google.com/presentation/d/120NtvswBSEvwd2Gjmj2v9r_BDQ6n2PYEYY0dI3EB56w/edit#slide=id.g56099e1461_1_0

[103] User activation: different concepts for different usages · Issue #3859 · whatwg/html · GitHub, https://github.com/whatwg/html/issues/3859

[104] GitHub - WICG/gesture-delegation: Gesture Delegation API proposal, https://github.com/WICG/gesture-delegation

[105] User Activation: ability to transfer activation to another frame · Issue #4364 · whatwg/html · GitHub, https://github.com/whatwg/html/issues/4364

[106] Activation Delegation through Transfer - Google ドキュメント, https://docs.google.com/document/d/1NKLJ2MBa9lA_FKRgD2ZIO7vIftOJ_YiXXMYfRMdlV-s/edit

[107] GitHub - dtapuska/useractivation, https://github.com/dtapuska/useractivation