Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | |
| 3 <head> | |
| 4 <script src="../../resources/testharness.js"></script> | 2 <script src="../../resources/testharness.js"></script> |
| 5 <script src="../../resources/testharnessreport.js"></script> | 3 <script src="../../resources/testharnessreport.js"></script> |
| 4 <iframe allow="vibrate"></iframe> | |
| 6 <script> | 5 <script> |
| 7 if (window.testRunner) { | 6 var srcs = [ |
| 8 testRunner.dumpAsText(); | 7 "resources/feature-policy-vibrate.html", |
| 9 testRunner.dumpChildFramesAsText(); | 8 "http://localhost:8000/feature-policy-experimental-features/resources/feature- policy-vibrate.html"]; |
| 9 | |
| 10 function sendClick() { | |
|
iclelland
2017/05/18 19:40:59
This function could probably be moved into a littl
lunalu1
2017/05/19 20:54:08
Done
| |
| 11 // The iframe uses eventSender to emulate a user navigatation, which requires | |
| 12 // absolute coordinates. | |
| 13 this.contentWindow.postMessage({x: this.offsetLeft, y: this.offsetTop}, "*"); | |
| 10 } | 14 } |
| 11 | 15 |
| 12 function loaded() { | 16 window.onload = function () { |
| 13 var iframes = document.getElementsByTagName('iframe'); | 17 var iframe = document.querySelector('iframe'); |
| 14 for (var i = 0; i < iframes.length; ++i) { // < 1; ++i) { // | 18 iframe.addEventListener('load', sendClick); |
| 15 var iframe = iframes[i]; | 19 function loadFrame(src) { |
| 16 // The iframe uses eventSender to emulate a user navigatation, which require s absolute coordinates. | 20 promise_test(function() { |
| 17 iframe.contentWindow.postMessage({x: iframe.offsetLeft, y: iframe.offsetTop} , "*"); | 21 iframe.src = src; |
| 22 return new Promise(function(resolve, reject) { | |
| 23 window.addEventListener('message', function(e) { | |
| 24 if (e.data.type === 'result') { | |
| 25 resolve(e.data); | |
| 26 } | |
| 27 }); | |
| 28 }).then(function(data) { | |
| 29 assert_true(data.enabled, 'navigator.vibrate():'); | |
| 30 }); | |
| 31 }, 'Navigator.vibrate enabled by container policy on URL: ' + src); | |
| 32 } | |
| 33 for (var src of srcs) { | |
| 34 loadFrame(src); | |
|
iclelland
2017/05/18 19:36:12
Will/could this set the iframe src attribute a sec
iclelland
2017/05/18 19:56:58
I had a look, to re-learn how promise_test worked,
lunalu1
2017/05/19 20:54:08
:)
| |
| 18 } | 35 } |
| 19 } | 36 } |
| 20 </script> | 37 </script> |
| 21 </head> | |
| 22 <body onload="loaded();"> | |
| 23 <iframe id="f1" src="resources/feature-policy-vibrate-enabled.html" allow="vibra te"></iframe> | |
| 24 <iframe id="f2" src="http://localhost:8000/feature-policy/feature-policy-vibrate -enabled.html" allow="vibrate"></iframe> | |
| 25 </body> | |
| 26 </html> | |
| OLD | NEW |