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

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: 'git cl format --js' for js/html 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 // TODO(leonhsl): Add more test cases http://crbug.com/701288
14
15 vibration_test(vibration => {
16 let mockForSubFrame = new vibration.MockVibrationManager;
17 let promise = new Promise(resolve => {
18 let iframe = document.createElement('iframe');
19 iframe.src = 'resources/vibrate-from-iframe.html';
20 iframe.onload = () => {
21 iframe.contentWindow.gin.define(
22 'Mojo Service Registry', ['content/public/renderer/frame_interfaces'],
23 (frameInterfaces) => {
24 frameInterfaces.addInterfaceOverrideForTesting(
25 vibration.VibrationManager.name, handle => {
26 mockForSubFrame.bindingSet.addBinding(
27 mockForSubFrame, handle);
28 });
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(mockForSubFrame.getDuration(), 1234);
49 assert_true(mockForSubFrame.isCancelled());
50 });
51 }, 'Iframe reload cancels vibration started by it before.');
52
53 vibration_test(vibration => {
54 let mockForSubFrame = new vibration.MockVibrationManager;
55 let promise = new Promise(resolve => {
56 let iframe = document.createElement('iframe');
57 iframe.src = 'resources/vibrate-from-iframe.html';
58 iframe.onload = () => {
59 iframe.contentWindow.gin.define(
60 'Mojo Service Registry', ['content/public/renderer/frame_interfaces'],
61 (frameInterfaces) => {
62 frameInterfaces.addInterfaceOverrideForTesting(
63 vibration.VibrationManager.name, handle => {
64 mockForSubFrame.bindingSet.addBinding(
65 mockForSubFrame, handle);
66 });
67 iframe.contentWindow.postMessage('Ready', '*');
68 });
69 };
70
71 document.body.appendChild(iframe);
72
73 window.onmessage = msg => {
74 if (msg.data === 'Vibrate') {
75 // Destroy the sub frame.
76 document.body.removeChild(iframe);
77 } else if (msg.data === 'Cancel') {
78 // Cancel is triggered by sub frame destroy on above.
79 resolve(msg.data);
80 }
81 };
82 });
83
84 return promise.then(msgData => {
85 assert_equals(msgData, 'Cancel');
86 assert_equals(mockForSubFrame.getDuration(), 1234);
87 assert_true(mockForSubFrame.isCancelled());
88 });
89 }, 'Iframe destroy cancels vibration started by it before.');
90
91 </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