Bug 1458443 [wpt PR 10753] - [KeyboardLock] Ensure API is called from a top-level browsing context, a=testonly
authorJoe Downing <joedow@chromium.org>
Thu, 03 May 2018 22:26:40 +0000
changeset 417327 e35a7833e4af226b8a5f8b9a4f9213536cd1ff71
parent 417326 d1e88f9ef9f4e53681559f5715a2146540a1f637
child 417328 485c8206b47c1bfc373b406e7a64bfbeeb7b4817
push id103033
push userjames@hoppipolla.co.uk
push dateTue, 08 May 2018 14:56:44 +0000
treeherdermozilla-inbound@8240a8e38db8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1458443, 10753, 680809, 1038888, 555417
milestone62.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1458443 [wpt PR 10753] - [KeyboardLock] Ensure API is called from a top-level browsing context, a=testonly Automatic update from web-platform-tests[KeyboardLock] Ensure API is called from a top-level browsing context This change adds some checks to the keyboard lock API to ensure it was called from within a supported context, otherwise it now rejects the promise. BUG=680809 Change-Id: I3d127422c640d16e43c22adb14755b65eb2cdc6a Reviewed-on: https://chromium-review.googlesource.com/1038888 Reviewed-by: Gary Kacmarcik <garykac@chromium.org> Commit-Queue: Joe Downing <joedow@chromium.org> Cr-Commit-Position: refs/heads/master@{#555417} -- wpt-commits: 90e225b4f5b37986c06f29bd305b0291a30e4867 wpt-pr: 10753
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/keyboard-lock/navigator-keyboard-lock-blocked-from-iframe.https.html
testing/web-platform/tests/keyboard-lock/resources/iframe-lock-helper.html
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -288462,16 +288462,21 @@
      {}
     ]
    ],
    "js/builtins/Promise-incumbent-global-subsubframe.sub.html": [
     [
      {}
     ]
    ],
+   "keyboard-lock/resources/iframe-lock-helper.html": [
+    [
+     {}
+    ]
+   ],
    "longtask-timing/OWNERS": [
     [
      {}
     ]
    ],
    "longtask-timing/resources/makelongtask.js": [
     [
      {}
@@ -343600,16 +343605,22 @@
     ]
    ],
    "keyboard-lock/idlharness.https.html": [
     [
      "/keyboard-lock/idlharness.https.html",
      {}
     ]
    ],
+   "keyboard-lock/navigator-keyboard-lock-blocked-from-iframe.https.html": [
+    [
+     "/keyboard-lock/navigator-keyboard-lock-blocked-from-iframe.https.html",
+     {}
+    ]
+   ],
    "keyboard-lock/navigator-keyboard-lock-two-parallel-requests.https.html": [
     [
      "/keyboard-lock/navigator-keyboard-lock-two-parallel-requests.https.html",
      {}
     ]
    ],
    "keyboard-lock/navigator-keyboard-lock-two-sequential-requests.https.html": [
     [
@@ -581015,32 +581026,40 @@
   "js/builtins/WeakMap.prototype-properties.html": [
    "581702f5f6b8f6e547918ae8f8a8547b103a9b6c",
    "testharness"
   ],
   "keyboard-lock/idlharness.https.html": [
    "010771094a9dc58e03a2c1ca2d8416866284fc2b",
    "testharness"
   ],
+  "keyboard-lock/navigator-keyboard-lock-blocked-from-iframe.https.html": [
+   "381b3ce858035d2829b6a004b007fa1d06c9938b",
+   "testharness"
+  ],
   "keyboard-lock/navigator-keyboard-lock-two-parallel-requests.https.html": [
    "8d0517d7f78890aead8376dfa314220180d48b3e",
    "testharness"
   ],
   "keyboard-lock/navigator-keyboard-lock-two-sequential-requests.https.html": [
    "3bb9f7f6103efd0d58d394e65071d3aedb02035d",
    "testharness"
   ],
   "keyboard-lock/navigator-keyboard-lock.https.html": [
    "6162fc3da9b7b104453e24b5da10d816a1a9425e",
    "testharness"
   ],
   "keyboard-lock/navigator-keyboard-unlock.https.html": [
    "f5cc2141ea7c74964d308784901d6d2c242f4369",
    "testharness"
   ],
+  "keyboard-lock/resources/iframe-lock-helper.html": [
+   "2ac2738dd428f3937fc2fd15dae2f98df5e3feb1",
+   "support"
+  ],
   "longtask-timing/OWNERS": [
    "30a9c29ba53bac131c0cca801c01dddb4779824e",
    "support"
   ],
   "longtask-timing/longtask-attributes.html": [
    "247359327818f59871be00d22942f6ecde5281a7",
    "testharness"
   ],
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/keyboard-lock/navigator-keyboard-lock-blocked-from-iframe.https.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<body>
+<script>
+'use strict';
+
+promise_test(() => {
+  let iframe = document.createElement('iframe');
+  iframe.src = 'resources/iframe-lock-helper.html';
+  iframe.onload = () => {
+    iframe.contentWindow.postMessage('Ready', '*');
+  }
+
+  document.body.appendChild(iframe);
+
+  return new Promise((resolve,reject) => {
+    window.onmessage = message => {
+      if (message.data == 'Success') {
+        resolve();
+      } else if (message.data == 'Failure') {
+        reject();
+      }
+    }
+  });
+}, '[Keyboard Lock] navigator.keyboard.lock blocked from within iframe');
+
+</script>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/keyboard-lock/resources/iframe-lock-helper.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<script>
+'use strict';
+
+window.onmessage = message => {
+  if (message.data === 'Ready') {
+    let onSuccess = () => { parent.postMessage('Failure', '*'); };
+    let onError = error => {
+      if (error.name == 'InvalidStateError') {
+        parent.postMessage('Success', '*');
+      } else {
+        parent.postMessage('Failure', '*');
+      }
+    };
+
+    navigator.keyboard.lock().then(onSuccess, onError);
+  }
+};
+
+</script>