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

Unified Diff: third_party/WebKit/LayoutTests/inspector-protocol/resources/device-emulator.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/resources/device-emulator.js
diff --git a/third_party/WebKit/LayoutTests/inspector-protocol/resources/device-emulator.js b/third_party/WebKit/LayoutTests/inspector-protocol/resources/device-emulator.js
new file mode 100644
index 0000000000000000000000000000000000000000..9040dc45722c087cf6cc4020fd335e5c8b2634e0
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/inspector-protocol/resources/device-emulator.js
@@ -0,0 +1,36 @@
+(class DeviceEmulator {
+ constructor(testRunner, session) {
+ this._testRunner = testRunner;
+ this._session = session;
+ }
+
+ async emulate(width, height, deviceScaleFactor, insets) {
+ this._testRunner.log(`Emulating device: ${width}x${height}x${deviceScaleFactor}`);
+ var full = !!width && !!height && !!deviceScaleFactor;
+ var params = {
+ width,
+ height,
+ deviceScaleFactor,
+ mobile: true,
+ fitWindow: false,
+ scale: 1,
+ screenWidth: width,
+ screenHeight: height,
+ positionX: 0,
+ positionY: 0
+ };
+ if (insets) {
+ params.screenWidth += insets.left + insets.right;
+ params.positionX = insets.left;
+ params.screenHeight += insets.top + insets.bottom;
+ params.positionY = insets.top;
+ }
+ var response = await this._session.protocol.Emulation.setDeviceMetricsOverride(params);
+ if (response.error)
+ this._testRunner.log('Error: ' + response.error);
+ }
+
+ async clear() {
+ await this._session.protocol.Emulation.clearDeviceMetricsOverride();
+ }
+})

Powered by Google App Engine
This is Rietveld 408576698