chrome-devtools-frontend 1.0.1016075 → 1.0.1016605

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -81,7 +81,15 @@ export class LighthousePanel extends UI.Panel.Panel {
81
81
  private rightToolbar!: UI.Toolbar.Toolbar;
82
82
  private showSettingsPaneSetting!: Common.Settings.Setting<boolean>;
83
83
  private stateBefore?: {
84
- emulation: {enabled: boolean, outlineEnabled: boolean, toolbarControlsEnabled: boolean},
84
+ emulation: {
85
+ type: EmulationModel.DeviceModeModel.Type,
86
+ enabled: boolean,
87
+ outlineEnabled: boolean,
88
+ toolbarControlsEnabled: boolean,
89
+ scale: number,
90
+ device: EmulationModel.EmulatedDevices.EmulatedDevice|null,
91
+ mode: EmulationModel.EmulatedDevices.Mode|null,
92
+ },
85
93
  network: {conditions: SDK.NetworkManager.Conditions},
86
94
  };
87
95
  private isLHAttached?: boolean;
@@ -385,7 +393,7 @@ export class LighthousePanel extends UI.Panel.Panel {
385
393
  }
386
394
 
387
395
  } catch (err) {
388
- await this.resetEmulationAndProtocolConnection();
396
+ await this.restoreEmulationAndProtocolConnection();
389
397
  if (err instanceof Error) {
390
398
  this.statusView.renderBugReport(err);
391
399
  }
@@ -413,12 +421,12 @@ export class LighthousePanel extends UI.Panel.Panel {
413
421
 
414
422
  Host.userMetrics.actionTaken(Host.UserMetrics.Action.LighthouseFinished);
415
423
 
416
- await this.resetEmulationAndProtocolConnection();
424
+ await this.restoreEmulationAndProtocolConnection();
417
425
  this.buildReportUI(lighthouseResponse.lhr, lighthouseResponse.artifacts);
418
426
  // Give focus to the new audit button when completed
419
427
  this.newButton.element.focus();
420
428
  } catch (err) {
421
- await this.resetEmulationAndProtocolConnection();
429
+ await this.restoreEmulationAndProtocolConnection();
422
430
  if (err instanceof Error) {
423
431
  this.statusView.renderBugReport(err);
424
432
  }
@@ -430,7 +438,7 @@ export class LighthousePanel extends UI.Panel.Panel {
430
438
  private async cancelLighthouse(): Promise<void> {
431
439
  this.currentLighthouseRun = undefined;
432
440
  this.statusView.updateStatus(i18nString(UIStrings.cancelling));
433
- await this.resetEmulationAndProtocolConnection();
441
+ await this.restoreEmulationAndProtocolConnection();
434
442
  this.renderStartView();
435
443
  }
436
444
 
@@ -447,9 +455,13 @@ export class LighthousePanel extends UI.Panel.Panel {
447
455
  const emulationModel = EmulationModel.DeviceModeModel.DeviceModeModel.instance();
448
456
  this.stateBefore = {
449
457
  emulation: {
458
+ type: emulationModel.type(),
450
459
  enabled: emulationModel.enabledSetting().get(),
451
460
  outlineEnabled: emulationModel.deviceOutlineSetting().get(),
452
461
  toolbarControlsEnabled: emulationModel.toolbarControlsEnabledSetting().get(),
462
+ scale: emulationModel.scaleSetting().get(),
463
+ device: emulationModel.device(),
464
+ mode: emulationModel.mode(),
453
465
  },
454
466
  network: {conditions: SDK.NetworkManager.MultitargetNetworkManager.instance().networkConditions()},
455
467
  };
@@ -473,7 +485,7 @@ export class LighthousePanel extends UI.Panel.Panel {
473
485
  this.isLHAttached = true;
474
486
  }
475
487
 
476
- private async resetEmulationAndProtocolConnection(): Promise<void> {
488
+ private async restoreEmulationAndProtocolConnection(): Promise<void> {
477
489
  if (!this.isLHAttached) {
478
490
  return;
479
491
  }
@@ -483,9 +495,25 @@ export class LighthousePanel extends UI.Panel.Panel {
483
495
 
484
496
  if (this.stateBefore) {
485
497
  const emulationModel = EmulationModel.DeviceModeModel.DeviceModeModel.instance();
486
- emulationModel.enabledSetting().set(this.stateBefore.emulation.enabled);
487
- emulationModel.deviceOutlineSetting().set(this.stateBefore.emulation.outlineEnabled);
488
- emulationModel.toolbarControlsEnabledSetting().set(this.stateBefore.emulation.toolbarControlsEnabled);
498
+
499
+ // Detaching a session after overriding device metrics will prevent other sessions from overriding device metrics in the future.
500
+ // A workaround is to call "Emulation.clearDeviceMetricOverride" which is the result of the next line.
501
+ // https://bugs.chromium.org/p/chromium/issues/detail?id=1337089
502
+ emulationModel.emulate(EmulationModel.DeviceModeModel.Type.None, null, null);
503
+
504
+ const {type, enabled, outlineEnabled, toolbarControlsEnabled, scale, device, mode} = this.stateBefore.emulation;
505
+ emulationModel.enabledSetting().set(enabled);
506
+ emulationModel.deviceOutlineSetting().set(outlineEnabled);
507
+ emulationModel.toolbarControlsEnabledSetting().set(toolbarControlsEnabled);
508
+
509
+ // `emulate` will ignore the `scale` parameter for responsive emulation.
510
+ // In this case we can just set it here.
511
+ if (type === EmulationModel.DeviceModeModel.Type.Responsive) {
512
+ emulationModel.scaleSetting().set(scale);
513
+ }
514
+
515
+ emulationModel.emulate(type, device, mode, scale);
516
+
489
517
  SDK.NetworkManager.MultitargetNetworkManager.instance().setNetworkConditions(this.stateBefore.network.conditions);
490
518
  delete this.stateBefore;
491
519
  }
package/package.json CHANGED
@@ -55,5 +55,5 @@
55
55
  "unittest": "scripts/test/run_unittests.py --no-text-coverage",
56
56
  "watch": "vpython third_party/node/node.py --output scripts/watch_build.js"
57
57
  },
58
- "version": "1.0.1016075"
58
+ "version": "1.0.1016605"
59
59
  }