forked from web-platform-tests/wpt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add keyboard-map to the feature policy.
This CL adds "keyboard-map" value to the allow attribute list so the Keyboard interface can be accessed from iframe. This is discussed here: WICG/keyboard-map#38 i2s: https://groups.google.com/a/chromium.org/g/blink-dev/c/SJD5Z4_E5TQ/m/B-f1WtnYBwAJ?utm_medium=email&utm_source=footer Bug: 1258242 Change-Id: Ic2427c88c649cd85b257de4f94f63fd3ce63364e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3218437 Reviewed-by: Daniel Cheng <[email protected]> Reviewed-by: Bo <[email protected]> Commit-Queue: Anupam Snigdha <[email protected]> Cr-Commit-Position: refs/heads/main@{#931354}
- Loading branch information
1 parent
0a8c303
commit 3fd50d5
Showing
5 changed files
with
78 additions
and
2 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
keyboard-map/navigator-keyboard-map-allowed-from-cross-origin-iframe.https.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<!DOCTYPE html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/cors/support.js?pipe=sub"></script> | ||
<body> | ||
<script> | ||
'use strict'; | ||
|
||
promise_test(() => { | ||
let iframe = document.createElement('iframe'); | ||
iframe.src = CROSSDOMAIN + 'resources/iframe-keyboard-map-allow-helper.html'; | ||
iframe.allow = "keyboard-map"; | ||
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 Map] getLayoutMap() allowed from within cross-origin iframe'); | ||
|
||
</script> |
29 changes: 29 additions & 0 deletions
29
keyboard-map/navigator-keyboard-map-allowed-from-iframe.https.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<!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-keyboard-map-allow-helper.html'; | ||
iframe.allow = "keyboard-map"; | ||
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 Map] getLayoutMap() allowed from within iframe'); | ||
|
||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
keyboard-map/resources/iframe-keyboard-map-allow-helper.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<!DOCTYPE html> | ||
<script> | ||
'use strict'; | ||
|
||
window.onmessage = message => { | ||
if (message.data === 'Ready') { | ||
let onSuccess = () => { parent.postMessage('Success', '*'); }; | ||
let onError = error => { | ||
parent.postMessage('Failure', '*'); | ||
}; | ||
|
||
navigator.keyboard.getLayoutMap().then(onSuccess, onError).catch(onError); | ||
} | ||
}; | ||
|
||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters