Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(190)

Side by Side Diff: third_party/WebKit/LayoutTests/vibration/vibration-iframe.html

Issue 2731953003: [DeviceService] Replace vibration_browsertest.cc with layout tests. (Closed)
Patch Set: Add case: reload subframe Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/vibration/vibration.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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>
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/vibration/vibration.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698