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

Unified 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, 6 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
Index: third_party/WebKit/LayoutTests/inspector-protocol/emulation/device-emulation-partial.js
diff --git a/third_party/WebKit/LayoutTests/inspector-protocol/emulation/device-emulation-partial.js b/third_party/WebKit/LayoutTests/inspector-protocol/emulation/device-emulation-partial.js
new file mode 100644
index 0000000000000000000000000000000000000000..8d3c637ff07f1dd4131692aa8455565fb54220ab
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/inspector-protocol/emulation/device-emulation-partial.js
@@ -0,0 +1,95 @@
+(async function(testRunner) {
+ let {page, session, dp} = await testRunner.startHTML(`
+ <head>
+ <style>
+ body {
+ margin: 0;
+ min-height: 1000px;
+ }
+ </style>
+ </head>
+ `, 'Tests that overriding only a single parameter does not affect others.');
+
+ function dumpMetrics() {
+ return JSON.stringify({
+ width: window.innerWidth,
+ height: window.innerHeight,
+ screenWidth: window.screen.width,
+ screenHeight: window.screen.height,
+ screenX: window.screenX,
+ screenY: window.screenY,
+ deviceScaleFactor: window.devicePixelRatio
+ });
+ }
+
+ var initialMetrics;
+
+ async function testPartialOverride(name, value) {
+ var params = {width: 0, height: 0, deviceScaleFactor: 0, mobile: false, fitWindow: false};
+ if (name === null) {
+ await dp.Emulation.clearDeviceMetricsOverride();
+ } else {
+ if (name)
+ params[name] = value;
+ await dp.Emulation.setDeviceMetricsOverride(params);
+ }
+
+ var metrics = JSON.parse(await session.evaluate(dumpMetrics));
+ var fail = false;
+ for (var key in initialMetrics) {
+ var expected = key === name ? value : initialMetrics[key];
+ if (metrics[key] !== expected) {
+ testRunner.log('[FAIL]: ' + metrics[key] + ' instead of ' + expected + ' for ' + key);
+ fail = true;
+ }
+ }
+ if (!fail)
+ testRunner.log(name ? ('[PASS]: ' + name + '=' + value) : '[PASS]');
+ }
+
+ await testRunner.runTestSuite([
+ async function collectMetrics() {
+ initialMetrics = JSON.parse(await session.evaluate(dumpMetrics));
+ },
+
+ async function noOverrides() {
+ await testPartialOverride('', 0);
+ },
+
+ async function width() {
+ await testPartialOverride('width', 300);
+ },
+
+ async function height() {
+ await testPartialOverride('height', 400);
+ },
+
+ async function deviceScaleFactor1() {
+ await testPartialOverride('deviceScaleFactor', 1);
+ },
+
+ async function deviceScaleFactor2() {
+ await testPartialOverride('deviceScaleFactor', 2);
+ },
+
+ async function clear() {
+ await testPartialOverride(null, null);
+ },
+
+ async function anotherWidth() {
+ await testPartialOverride('width', 400);
+ },
+
+ async function anotherHeight() {
+ await testPartialOverride('height', 300);
+ },
+
+ async function deviceScaleFactor3() {
+ await testPartialOverride('deviceScaleFactor', 3);
+ },
+
+ async function clear() {
+ await testPartialOverride(null, null);
+ }
+ ]);
+})

Powered by Google App Engine
This is Rietveld 408576698