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

Side by Side Diff: third_party/WebKit/LayoutTests/inspector-protocol/emulation/device-emulation-partial.js

Issue 2960023003: [DevTools] Migrate inspector-protocol/emulation tests to new harness (Closed)
Patch Set: Created 3 years, 5 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
OLDNEW
(Empty)
1 (async function(testRunner) {
2 let {page, session, dp} = await testRunner.startHTML(`
3 <head>
4 <style>
5 body {
6 margin: 0;
7 min-height: 1000px;
8 }
9 </style>
10 </head>
11 `, 'Tests that overriding only a single parameter does not affect others.');
12
13 function dumpMetrics() {
14 return JSON.stringify({
15 width: window.innerWidth,
16 height: window.innerHeight,
17 screenWidth: window.screen.width,
18 screenHeight: window.screen.height,
19 screenX: window.screenX,
20 screenY: window.screenY,
21 deviceScaleFactor: window.devicePixelRatio
22 });
23 }
24
25 var initialMetrics;
26
27 async function testPartialOverride(name, value) {
28 var params = {width: 0, height: 0, deviceScaleFactor: 0, mobile: false, fitW indow: false};
29 if (name === null) {
30 await dp.Emulation.clearDeviceMetricsOverride();
31 } else {
32 if (name)
33 params[name] = value;
34 await dp.Emulation.setDeviceMetricsOverride(params);
35 }
36
37 var metrics = JSON.parse(await session.evaluate(dumpMetrics));
38 var fail = false;
39 for (var key in initialMetrics) {
40 var expected = key === name ? value : initialMetrics[key];
41 if (metrics[key] !== expected) {
42 testRunner.log('[FAIL]: ' + metrics[key] + ' instead of ' + expected + ' for ' + key);
43 fail = true;
44 }
45 }
46 if (!fail)
47 testRunner.log(name ? ('[PASS]: ' + name + '=' + value) : '[PASS]');
48 }
49
50 await testRunner.runTestSuite([
51 async function collectMetrics() {
52 initialMetrics = JSON.parse(await session.evaluate(dumpMetrics));
53 },
54
55 async function noOverrides() {
56 await testPartialOverride('', 0);
57 },
58
59 async function width() {
60 await testPartialOverride('width', 300);
61 },
62
63 async function height() {
64 await testPartialOverride('height', 400);
65 },
66
67 async function deviceScaleFactor1() {
68 await testPartialOverride('deviceScaleFactor', 1);
69 },
70
71 async function deviceScaleFactor2() {
72 await testPartialOverride('deviceScaleFactor', 2);
73 },
74
75 async function clear() {
76 await testPartialOverride(null, null);
77 },
78
79 async function anotherWidth() {
80 await testPartialOverride('width', 400);
81 },
82
83 async function anotherHeight() {
84 await testPartialOverride('height', 300);
85 },
86
87 async function deviceScaleFactor3() {
88 await testPartialOverride('deviceScaleFactor', 3);
89 },
90
91 async function clear() {
92 await testPartialOverride(null, null);
93 }
94 ]);
95 })
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698