summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/keyboard-map/resources/iframe-keyboard-map-helper.html
blob: 7438029a19ba67feba171453d5c82b886d1208c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<!DOCTYPE html>
<script>
'use strict';

window.onmessage = message => {
  if (message.data === 'Ready') {
    let onSuccess = () => { parent.postMessage('Failure', '*'); };
    let onError = error => {
      if (error.name == 'SecurityError') {
        parent.postMessage('Success', '*');
      } else {
        parent.postMessage('Failure', '*');
      }
    };

    navigator.keyboard.getLayoutMap().then(onSuccess, onError).catch(onError);
  }
};

</script>