Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <script src="../resources/testharness.js"></script> | |
| 3 <script src="../resources/testharnessreport.js"></script> | |
| 4 <script src="../resources/mojo-helpers.js"></script> | |
| 5 <script src="resources/vibration-helpers.js"></script> | |
| 6 <script> | |
| 7 | |
| 8 'use strict'; | |
| 9 | |
| 10 if (!window.testRunner) | |
| 11 debug('This test cannot be run without the TestRunner'); | |
| 12 | |
| 13 // Cover test case in vibration_browsertest.cc: | |
| 14 // CancelVibrationFromSubFrameWhenMainFrameIsReloaded | |
| 15 vibration_test(vibration => { | |
| 16 let promise = new Promise(resolve => { | |
| 17 let mockForSubFrame = new vibration.MockVibrationManager; | |
| 18 let iframe = document.createElement('iframe'); | |
| 19 iframe.src = 'resources/vibrate-from-iframe.html'; | |
|
leonhsl(Using Gerrit)
2017/03/09 08:34:10
This test case is created by mimicking nfc layout
blundell
2017/03/09 16:56:35
What I tend to do in cases like this is simple pri
| |
| 20 iframe.onload = () => { | |
| 21 iframe.contentWindow.gin.define( | |
| 22 "Mojo Service Registry", | |
| 23 [ 'content/public/renderer/frame_interfaces' ], | |
| 24 (frameInterfaces) => { | |
| 25 frameInterfaces.addInterfaceOverrideForTesting( | |
| 26 vibration.VibrationManager.name, | |
| 27 handle => { mockForSubFrame.bindingSet.addBinding( | |
| 28 mockForSubFrame, handle); }); | |
| 29 iframe.contentWindow.postMessage('Ready', '*'); | |
| 30 }); | |
| 31 }; | |
| 32 | |
| 33 document.body.appendChild(iframe); | |
| 34 | |
| 35 window.onmessage = msg => { | |
| 36 if (msg.data === 'Vibrate') { | |
| 37 // Navigate the sub frame. | |
| 38 iframe.src = 'about:blank'; | |
| 39 } else if (msg.data === 'Cancel') { | |
| 40 // Cancel is triggered by sub frame navigation on above. | |
| 41 resolve(msg.data); | |
| 42 } | |
| 43 }; | |
| 44 }); | |
| 45 | |
| 46 return promise.then(msgData => { | |
| 47 assert_equals(msgData, 'Cancel'); | |
| 48 assert_equals(vibration.mockVibrationManager.getDuration(), 1234); | |
| 49 assert_true(vibration.mockVibrationManager.isCancelled()); | |
| 50 }); | |
| 51 }, 'Iframe reload would cancel the vibration started by it before.'); | |
| 52 | |
| 53 </script> | |
| OLD | NEW |