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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/vibration/vibration.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/vibration/vibration-iframe.html
diff --git a/third_party/WebKit/LayoutTests/vibration/vibration-iframe.html b/third_party/WebKit/LayoutTests/vibration/vibration-iframe.html
new file mode 100644
index 0000000000000000000000000000000000000000..a05d31d06ee7614882804dc6a5c2148bb789773d
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/vibration/vibration-iframe.html
@@ -0,0 +1,53 @@
+<!DOCTYPE html>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script src="../resources/mojo-helpers.js"></script>
+<script src="resources/vibration-helpers.js"></script>
+<script>
+
+'use strict';
+
+if (!window.testRunner)
+ debug('This test cannot be run without the TestRunner');
+
+// Cover test case in vibration_browsertest.cc:
+// CancelVibrationFromSubFrameWhenMainFrameIsReloaded
+vibration_test(vibration => {
+ let promise = new Promise(resolve => {
+ let mockForSubFrame = new vibration.MockVibrationManager;
+ let iframe = document.createElement('iframe');
+ 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
+ iframe.onload = () => {
+ iframe.contentWindow.gin.define(
+ "Mojo Service Registry",
+ [ 'content/public/renderer/frame_interfaces' ],
+ (frameInterfaces) => {
+ frameInterfaces.addInterfaceOverrideForTesting(
+ vibration.VibrationManager.name,
+ handle => { mockForSubFrame.bindingSet.addBinding(
+ mockForSubFrame, handle); });
+ iframe.contentWindow.postMessage('Ready', '*');
+ });
+ };
+
+ document.body.appendChild(iframe);
+
+ window.onmessage = msg => {
+ if (msg.data === 'Vibrate') {
+ // Navigate the sub frame.
+ iframe.src = 'about:blank';
+ } else if (msg.data === 'Cancel') {
+ // Cancel is triggered by sub frame navigation on above.
+ resolve(msg.data);
+ }
+ };
+ });
+
+ return promise.then(msgData => {
+ assert_equals(msgData, 'Cancel');
+ assert_equals(vibration.mockVibrationManager.getDuration(), 1234);
+ assert_true(vibration.mockVibrationManager.isCancelled());
+ });
+}, 'Iframe reload would cancel the vibration started by it before.');
+
+</script>
« 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