Commit b4f93330 authored by dgozman's avatar dgozman Committed by Commit bot

[DevTools] Introduce EmulationModel which will encapsulate emulation

This ensures proper capability check. This is also the last domain
without proper model.

BUG=none

Review-Url: https://codereview.chromium.org/2843763004
Cr-Commit-Position: refs/heads/master@{#467547}
parent 1dcbddb0
...@@ -197,11 +197,9 @@ all_devtools_files = [ ...@@ -197,11 +197,9 @@ all_devtools_files = [
"front_end/emulation/deviceModeView.css", "front_end/emulation/deviceModeView.css",
"front_end/emulation/DeviceModeView.js", "front_end/emulation/DeviceModeView.js",
"front_end/emulation/DeviceModeWrapper.js", "front_end/emulation/DeviceModeWrapper.js",
"front_end/emulation/DeviceOrientation.js",
"front_end/emulation/devicesSettingsTab.css", "front_end/emulation/devicesSettingsTab.css",
"front_end/emulation/DevicesSettingsTab.js", "front_end/emulation/DevicesSettingsTab.js",
"front_end/emulation/EmulatedDevices.js", "front_end/emulation/EmulatedDevices.js",
"front_end/emulation/Geolocation.js",
"front_end/emulation/inspectedPagePlaceholder.css", "front_end/emulation/inspectedPagePlaceholder.css",
"front_end/emulation/InspectedPagePlaceholder.js", "front_end/emulation/InspectedPagePlaceholder.js",
"front_end/emulation/mediaQueryInspector.css", "front_end/emulation/mediaQueryInspector.css",
...@@ -209,7 +207,6 @@ all_devtools_files = [ ...@@ -209,7 +207,6 @@ all_devtools_files = [
"front_end/emulation/module.json", "front_end/emulation/module.json",
"front_end/emulation/sensors.css", "front_end/emulation/sensors.css",
"front_end/emulation/SensorsView.js", "front_end/emulation/SensorsView.js",
"front_end/emulation/TouchModel.js",
"front_end/event_listeners/EventListenersUtils.js", "front_end/event_listeners/EventListenersUtils.js",
"front_end/event_listeners/eventListenersView.css", "front_end/event_listeners/eventListenersView.css",
"front_end/event_listeners/EventListenersView.js", "front_end/event_listeners/EventListenersView.js",
...@@ -469,6 +466,7 @@ all_devtools_files = [ ...@@ -469,6 +466,7 @@ all_devtools_files = [
"front_end/sdk/DOMDebuggerModel.js", "front_end/sdk/DOMDebuggerModel.js",
"front_end/sdk/DebuggerModel.js", "front_end/sdk/DebuggerModel.js",
"front_end/sdk/DOMModel.js", "front_end/sdk/DOMModel.js",
"front_end/sdk/EmulationModel.js",
"front_end/sdk/FilmStripModel.js", "front_end/sdk/FilmStripModel.js",
"front_end/sdk/HeapProfilerModel.js", "front_end/sdk/HeapProfilerModel.js",
"front_end/sdk/LayerTreeBase.js", "front_end/sdk/LayerTreeBase.js",
......
...@@ -3,16 +3,16 @@ ...@@ -3,16 +3,16 @@
// found in the LICENSE file. // found in the LICENSE file.
/** /**
* @implements {SDK.TargetManager.Observer} * @implements {SDK.SDKModelObserver<!SDK.EmulationModel>}
*/ */
Components.CPUThrottlingManager = class extends Common.Object { Components.CPUThrottlingManager = class extends Common.Object {
constructor() { constructor() {
super(); super();
this._throttlingRate = 1; // No throttling this._throttlingRate = 1; // No throttling
SDK.targetManager.observeTargets(this, SDK.Target.Capability.Browser);
/** @type {!Set<!UI.ToolbarComboBox>} */ /** @type {!Set<!UI.ToolbarComboBox>} */
this._controls = new Set(); this._controls = new Set();
this._rates = [1, 2, 5, 10, 20]; this._rates = [1, 2, 5, 10, 20];
SDK.targetManager.observeModels(SDK.EmulationModel, this);
} }
/** /**
...@@ -20,7 +20,8 @@ Components.CPUThrottlingManager = class extends Common.Object { ...@@ -20,7 +20,8 @@ Components.CPUThrottlingManager = class extends Common.Object {
*/ */
_setRateIndex(index) { _setRateIndex(index) {
this._throttlingRate = this._rates[index]; this._throttlingRate = this._rates[index];
SDK.targetManager.targets().forEach(target => target.emulationAgent().setCPUThrottlingRate(this._throttlingRate)); for (var emulationModel of SDK.targetManager.models(SDK.EmulationModel))
emulationModel.setCPUThrottlingRate(this._throttlingRate);
var icon = null; var icon = null;
if (this._throttlingRate !== 1) { if (this._throttlingRate !== 1) {
Host.userMetrics.actionTaken(Host.UserMetrics.Action.CpuThrottlingEnabled); Host.userMetrics.actionTaken(Host.UserMetrics.Action.CpuThrottlingEnabled);
...@@ -42,18 +43,18 @@ Components.CPUThrottlingManager = class extends Common.Object { ...@@ -42,18 +43,18 @@ Components.CPUThrottlingManager = class extends Common.Object {
/** /**
* @override * @override
* @param {!SDK.Target} target * @param {!SDK.EmulationModel} emulationModel
*/ */
targetAdded(target) { modelAdded(emulationModel) {
if (this._throttlingRate !== 1) if (this._throttlingRate !== 1)
target.emulationAgent().setCPUThrottlingRate(this._throttlingRate); emulationModel.setCPUThrottlingRate(this._throttlingRate);
} }
/** /**
* @override * @override
* @param {!SDK.Target} target * @param {!SDK.EmulationModel} emulationModel
*/ */
targetRemoved(target) { modelRemoved(emulationModel) {
} }
/** /**
......
...@@ -675,7 +675,8 @@ Emulation.DeviceModeModel = class { ...@@ -675,7 +675,8 @@ Emulation.DeviceModeModel = class {
* @param {boolean} mobile * @param {boolean} mobile
*/ */
_applyTouch(touchEnabled, mobile) { _applyTouch(touchEnabled, mobile) {
Emulation.MultitargetTouchModel.instance().setTouchEnabled(touchEnabled, mobile); for (var emulationModel of SDK.targetManager.models(SDK.EmulationModel))
emulationModel.emulateTouch(touchEnabled, mobile);
} }
}; };
......
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* @unrestricted
*/
Emulation.DeviceOrientation = class {
/**
* @param {number} alpha
* @param {number} beta
* @param {number} gamma
*/
constructor(alpha, beta, gamma) {
this.alpha = alpha;
this.beta = beta;
this.gamma = gamma;
}
/**
* @return {!Emulation.DeviceOrientation}
*/
static parseSetting(value) {
if (value) {
var jsonObject = JSON.parse(value);
return new Emulation.DeviceOrientation(jsonObject.alpha, jsonObject.beta, jsonObject.gamma);
}
return new Emulation.DeviceOrientation(0, 0, 0);
}
/**
* @return {?Emulation.DeviceOrientation}
*/
static parseUserInput(alphaString, betaString, gammaString) {
if (!alphaString && !betaString && !gammaString)
return null;
var isAlphaValid = Emulation.DeviceOrientation.validator(alphaString);
var isBetaValid = Emulation.DeviceOrientation.validator(betaString);
var isGammaValid = Emulation.DeviceOrientation.validator(gammaString);
if (!isAlphaValid && !isBetaValid && !isGammaValid)
return null;
var alpha = isAlphaValid ? parseFloat(alphaString) : -1;
var beta = isBetaValid ? parseFloat(betaString) : -1;
var gamma = isGammaValid ? parseFloat(gammaString) : -1;
return new Emulation.DeviceOrientation(alpha, beta, gamma);
}
/**
* @param {string} value
* @return {boolean}
*/
static validator(value) {
return /^([+-]?[\d]+(\.\d+)?|[+-]?\.\d+)$/.test(value);
}
/**
* @return {string}
*/
toSetting() {
return JSON.stringify(this);
}
apply() {
for (var target of SDK.targetManager.targets(SDK.Target.Capability.Browser))
target.deviceOrientationAgent().setDeviceOrientationOverride(this.alpha, this.beta, this.gamma);
}
clear() {
for (var target of SDK.targetManager.targets(SDK.Target.Capability.Browser))
target.deviceOrientationAgent().clearDeviceOrientationOverride();
}
};
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* @unrestricted
*/
Emulation.Geolocation = class {
/**
* @param {number} latitude
* @param {number} longitude
* @param {boolean} error
*/
constructor(latitude, longitude, error) {
this.latitude = latitude;
this.longitude = longitude;
this.error = error;
}
/**
* @return {!Emulation.Geolocation}
*/
static parseSetting(value) {
if (value) {
var splitError = value.split(':');
if (splitError.length === 2) {
var splitPosition = splitError[0].split('@');
if (splitPosition.length === 2)
return new Emulation.Geolocation(parseFloat(splitPosition[0]), parseFloat(splitPosition[1]), splitError[1]);
}
}
return new Emulation.Geolocation(0, 0, false);
}
/**
* @param {string} latitudeString
* @param {string} longitudeString
* @param {string} errorStatus
* @return {?Emulation.Geolocation}
*/
static parseUserInput(latitudeString, longitudeString, errorStatus) {
if (!latitudeString && !longitudeString)
return null;
var isLatitudeValid = Emulation.Geolocation.latitudeValidator(latitudeString);
var isLongitudeValid = Emulation.Geolocation.longitudeValidator(longitudeString);
if (!isLatitudeValid && !isLongitudeValid)
return null;
var latitude = isLatitudeValid ? parseFloat(latitudeString) : -1;
var longitude = isLongitudeValid ? parseFloat(longitudeString) : -1;
return new Emulation.Geolocation(latitude, longitude, !!errorStatus);
}
/**
* @param {string} value
* @return {boolean}
*/
static latitudeValidator(value) {
var numValue = parseFloat(value);
return /^([+-]?[\d]+(\.\d+)?|[+-]?\.\d+)$/.test(value) && numValue >= -90 && numValue <= 90;
}
/**
* @param {string} value
* @return {boolean}
*/
static longitudeValidator(value) {
var numValue = parseFloat(value);
return /^([+-]?[\d]+(\.\d+)?|[+-]?\.\d+)$/.test(value) && numValue >= -180 && numValue <= 180;
}
/**
* @return {string}
*/
toSetting() {
return (typeof this.latitude === 'number' && typeof this.longitude === 'number' && typeof this.error === 'string') ?
this.latitude + '@' + this.longitude + ':' + this.error :
'';
}
apply() {
for (var target of SDK.targetManager.targets(SDK.Target.Capability.Browser)) {
if (this.error) {
target.emulationAgent().setGeolocationOverride();
} else {
target.emulationAgent().setGeolocationOverride(
this.latitude, this.longitude, Emulation.Geolocation.DefaultMockAccuracy);
}
}
}
clear() {
for (var target of SDK.targetManager.targets(SDK.Target.Capability.Browser))
target.emulationAgent().clearGeolocationOverride();
}
};
Emulation.Geolocation.DefaultMockAccuracy = 150;
...@@ -11,14 +11,14 @@ Emulation.SensorsView = class extends UI.VBox { ...@@ -11,14 +11,14 @@ Emulation.SensorsView = class extends UI.VBox {
this.contentElement.classList.add('sensors-view'); this.contentElement.classList.add('sensors-view');
this._geolocationSetting = Common.settings.createSetting('emulation.geolocationOverride', ''); this._geolocationSetting = Common.settings.createSetting('emulation.geolocationOverride', '');
this._geolocation = Emulation.Geolocation.parseSetting(this._geolocationSetting.get()); this._geolocation = SDK.EmulationModel.Geolocation.parseSetting(this._geolocationSetting.get());
this._geolocationOverrideEnabled = false; this._geolocationOverrideEnabled = false;
this._createGeolocationSection(this._geolocation); this._createGeolocationSection(this._geolocation);
this.contentElement.createChild('div').classList.add('panel-section-separator'); this.contentElement.createChild('div').classList.add('panel-section-separator');
this._deviceOrientationSetting = Common.settings.createSetting('emulation.deviceOrientationOverride', ''); this._deviceOrientationSetting = Common.settings.createSetting('emulation.deviceOrientationOverride', '');
this._deviceOrientation = Emulation.DeviceOrientation.parseSetting(this._deviceOrientationSetting.get()); this._deviceOrientation = SDK.EmulationModel.DeviceOrientation.parseSetting(this._deviceOrientationSetting.get());
this._deviceOrientationOverrideEnabled = false; this._deviceOrientationOverrideEnabled = false;
this._createDeviceOrientationSection(); this._createDeviceOrientationSection();
...@@ -37,7 +37,7 @@ Emulation.SensorsView = class extends UI.VBox { ...@@ -37,7 +37,7 @@ Emulation.SensorsView = class extends UI.VBox {
} }
/** /**
* @param {!Emulation.Geolocation} geolocation * @param {!SDK.EmulationModel.Geolocation} geolocation
*/ */
_createGeolocationSection(geolocation) { _createGeolocationSection(geolocation) {
var geogroup = this.contentElement.createChild('section', 'sensors-group'); var geogroup = this.contentElement.createChild('section', 'sensors-group');
...@@ -80,15 +80,16 @@ Emulation.SensorsView = class extends UI.VBox { ...@@ -80,15 +80,16 @@ Emulation.SensorsView = class extends UI.VBox {
this._latitudeInput.setAttribute('type', 'number'); this._latitudeInput.setAttribute('type', 'number');
this._latitudeInput.value = 0; this._latitudeInput.value = 0;
this._latitudeSetter = UI.bindInput( this._latitudeSetter = UI.bindInput(
this._latitudeInput, this._applyGeolocationUserInput.bind(this), Emulation.Geolocation.latitudeValidator, true); this._latitudeInput, this._applyGeolocationUserInput.bind(this),
SDK.EmulationModel.Geolocation.latitudeValidator, true);
this._latitudeSetter(String(geolocation.latitude)); this._latitudeSetter(String(geolocation.latitude));
this._longitudeInput = longitudeGroup.createChild('input'); this._longitudeInput = longitudeGroup.createChild('input');
this._longitudeInput.setAttribute('type', 'number'); this._longitudeInput.setAttribute('type', 'number');
this._longitudeInput.value = 0; this._longitudeInput.value = 0;
this._longitudeSetter = UI.bindInput( this._longitudeSetter = UI.bindInput(
this._longitudeInput, this._applyGeolocationUserInput.bind(this), Emulation.Geolocation.longitudeValidator, this._longitudeInput, this._applyGeolocationUserInput.bind(this),
true); SDK.EmulationModel.Geolocation.longitudeValidator, true);
this._longitudeSetter(String(geolocation.longitude)); this._longitudeSetter(String(geolocation.longitude));
latitudeGroup.createChild('div', 'latlong-title').textContent = Common.UIString('Latitude'); latitudeGroup.createChild('div', 'latlong-title').textContent = Common.UIString('Latitude');
...@@ -105,11 +106,11 @@ Emulation.SensorsView = class extends UI.VBox { ...@@ -105,11 +106,11 @@ Emulation.SensorsView = class extends UI.VBox {
this._geolocationOverrideEnabled = true; this._geolocationOverrideEnabled = true;
} else if (value === Emulation.SensorsView.NonPresetOptions.Unavailable) { } else if (value === Emulation.SensorsView.NonPresetOptions.Unavailable) {
this._geolocationOverrideEnabled = true; this._geolocationOverrideEnabled = true;
this._geolocation = new Emulation.Geolocation(0, 0, true); this._geolocation = new SDK.EmulationModel.Geolocation(0, 0, true);
} else { } else {
this._geolocationOverrideEnabled = true; this._geolocationOverrideEnabled = true;
var coordinates = JSON.parse(value); var coordinates = JSON.parse(value);
this._geolocation = new Emulation.Geolocation(coordinates[0], coordinates[1], false); this._geolocation = new SDK.EmulationModel.Geolocation(coordinates[0], coordinates[1], false);
this._latitudeSetter(coordinates[0]); this._latitudeSetter(coordinates[0]);
this._longitudeSetter(coordinates[1]); this._longitudeSetter(coordinates[1]);
} }
...@@ -120,8 +121,8 @@ Emulation.SensorsView = class extends UI.VBox { ...@@ -120,8 +121,8 @@ Emulation.SensorsView = class extends UI.VBox {
} }
_applyGeolocationUserInput() { _applyGeolocationUserInput() {
var geolocation = var geolocation = SDK.EmulationModel.Geolocation.parseUserInput(
Emulation.Geolocation.parseUserInput(this._latitudeInput.value.trim(), this._longitudeInput.value.trim(), ''); this._latitudeInput.value.trim(), this._longitudeInput.value.trim(), '');
if (!geolocation) if (!geolocation)
return; return;
...@@ -131,12 +132,10 @@ Emulation.SensorsView = class extends UI.VBox { ...@@ -131,12 +132,10 @@ Emulation.SensorsView = class extends UI.VBox {
} }
_applyGeolocation() { _applyGeolocation() {
if (this._geolocationOverrideEnabled) { if (this._geolocationOverrideEnabled)
this._geolocationSetting.set(this._geolocation.toSetting()); this._geolocationSetting.set(this._geolocation.toSetting());
this._geolocation.apply(); for (var emulationModel of SDK.targetManager.models(SDK.EmulationModel))
} else { emulationModel.emulateGeolocation(this._geolocationOverrideEnabled ? this._geolocation : null);
this._geolocation.clear();
}
} }
_createDeviceOrientationSection() { _createDeviceOrientationSection() {
...@@ -220,19 +219,18 @@ Emulation.SensorsView = class extends UI.VBox { ...@@ -220,19 +219,18 @@ Emulation.SensorsView = class extends UI.VBox {
} else { } else {
var parsedValue = JSON.parse(value); var parsedValue = JSON.parse(value);
this._deviceOrientationOverrideEnabled = true; this._deviceOrientationOverrideEnabled = true;
this._deviceOrientation = new Emulation.DeviceOrientation(parsedValue[0], parsedValue[1], parsedValue[2]); this._deviceOrientation =
new SDK.EmulationModel.DeviceOrientation(parsedValue[0], parsedValue[1], parsedValue[2]);
this._setDeviceOrientation( this._setDeviceOrientation(
this._deviceOrientation, Emulation.SensorsView.DeviceOrientationModificationSource.SelectPreset); this._deviceOrientation, Emulation.SensorsView.DeviceOrientationModificationSource.SelectPreset);
} }
} }
_applyDeviceOrientation() { _applyDeviceOrientation() {
if (this._deviceOrientationOverrideEnabled) { if (this._deviceOrientationOverrideEnabled)
this._deviceOrientationSetting.set(this._deviceOrientation.toSetting()); this._deviceOrientationSetting.set(this._deviceOrientation.toSetting());
this._deviceOrientation.apply(); for (var emulationModel of SDK.targetManager.models(SDK.EmulationModel))
} else { emulationModel.emulateDeviceOrientation(this._deviceOrientationOverrideEnabled ? this._deviceOrientation : null);
this._deviceOrientation.clear();
}
} }
/** /**
...@@ -246,7 +244,7 @@ Emulation.SensorsView = class extends UI.VBox { ...@@ -246,7 +244,7 @@ Emulation.SensorsView = class extends UI.VBox {
_applyDeviceOrientationUserInput() { _applyDeviceOrientationUserInput() {
this._setDeviceOrientation( this._setDeviceOrientation(
Emulation.DeviceOrientation.parseUserInput( SDK.EmulationModel.DeviceOrientation.parseUserInput(
this._alphaElement.value.trim(), this._betaElement.value.trim(), this._gammaElement.value.trim()), this._alphaElement.value.trim(), this._betaElement.value.trim(), this._gammaElement.value.trim()),
Emulation.SensorsView.DeviceOrientationModificationSource.UserInput); Emulation.SensorsView.DeviceOrientationModificationSource.UserInput);
this._setSelectElementLabel(this._orientationSelectElement, Emulation.SensorsView.NonPresetOptions.Custom); this._setSelectElementLabel(this._orientationSelectElement, Emulation.SensorsView.NonPresetOptions.Custom);
...@@ -254,13 +252,13 @@ Emulation.SensorsView = class extends UI.VBox { ...@@ -254,13 +252,13 @@ Emulation.SensorsView = class extends UI.VBox {
_resetDeviceOrientation() { _resetDeviceOrientation() {
this._setDeviceOrientation( this._setDeviceOrientation(
new Emulation.DeviceOrientation(0, 90, 0), new SDK.EmulationModel.DeviceOrientation(0, 90, 0),
Emulation.SensorsView.DeviceOrientationModificationSource.ResetButton); Emulation.SensorsView.DeviceOrientationModificationSource.ResetButton);
this._setSelectElementLabel(this._orientationSelectElement, '[0, 90, 0]'); this._setSelectElementLabel(this._orientationSelectElement, '[0, 90, 0]');
} }
/** /**
* @param {?Emulation.DeviceOrientation} deviceOrientation * @param {?SDK.EmulationModel.DeviceOrientation} deviceOrientation
* @param {!Emulation.SensorsView.DeviceOrientationModificationSource} modificationSource * @param {!Emulation.SensorsView.DeviceOrientationModificationSource} modificationSource
*/ */
_setDeviceOrientation(deviceOrientation, modificationSource) { _setDeviceOrientation(deviceOrientation, modificationSource) {
...@@ -300,11 +298,11 @@ Emulation.SensorsView = class extends UI.VBox { ...@@ -300,11 +298,11 @@ Emulation.SensorsView = class extends UI.VBox {
div.createTextChild(label); div.createTextChild(label);
input.type = 'number'; input.type = 'number';
return UI.bindInput( return UI.bindInput(
input, this._applyDeviceOrientationUserInput.bind(this), Emulation.DeviceOrientation.validator, true); input, this._applyDeviceOrientationUserInput.bind(this), SDK.EmulationModel.DeviceOrientation.validator, true);
} }
/** /**
* @param {!Emulation.DeviceOrientation} deviceOrientation * @param {!SDK.EmulationModel.DeviceOrientation} deviceOrientation
* @return {!Element} * @return {!Element}
*/ */
_createDeviceOrientationOverrideElement(deviceOrientation) { _createDeviceOrientationOverrideElement(deviceOrientation) {
...@@ -330,7 +328,7 @@ Emulation.SensorsView = class extends UI.VBox { ...@@ -330,7 +328,7 @@ Emulation.SensorsView = class extends UI.VBox {
} }
/** /**
* @param {!Emulation.DeviceOrientation} deviceOrientation * @param {!SDK.EmulationModel.DeviceOrientation} deviceOrientation
* @param {boolean} animate * @param {boolean} animate
*/ */
_setBoxOrientation(deviceOrientation, animate) { _setBoxOrientation(deviceOrientation, animate) {
...@@ -375,7 +373,8 @@ Emulation.SensorsView = class extends UI.VBox { ...@@ -375,7 +373,8 @@ Emulation.SensorsView = class extends UI.VBox {
.multiply(this._originalBoxMatrix); .multiply(this._originalBoxMatrix);
var eulerAngles = UI.Geometry.EulerAngles.fromRotationMatrix(currentMatrix); var eulerAngles = UI.Geometry.EulerAngles.fromRotationMatrix(currentMatrix);
var newOrientation = new Emulation.DeviceOrientation(-eulerAngles.alpha, -eulerAngles.beta, eulerAngles.gamma); var newOrientation =
new SDK.EmulationModel.DeviceOrientation(-eulerAngles.alpha, -eulerAngles.beta, eulerAngles.gamma);
this._setDeviceOrientation(newOrientation, Emulation.SensorsView.DeviceOrientationModificationSource.UserDrag); this._setDeviceOrientation(newOrientation, Emulation.SensorsView.DeviceOrientationModificationSource.UserDrag);
this._setSelectElementLabel(this._orientationSelectElement, Emulation.SensorsView.NonPresetOptions.Custom); this._setSelectElementLabel(this._orientationSelectElement, Emulation.SensorsView.NonPresetOptions.Custom);
return false; return false;
...@@ -428,7 +427,8 @@ Emulation.SensorsView = class extends UI.VBox { ...@@ -428,7 +427,8 @@ Emulation.SensorsView = class extends UI.VBox {
select.addEventListener('change', applyTouch, false); select.addEventListener('change', applyTouch, false);
function applyTouch() { function applyTouch() {
Emulation.MultitargetTouchModel.instance().setCustomTouchEnabled(select.value === 'enabled'); for (var emulationModel of SDK.targetManager.models(SDK.EmulationModel))
emulationModel.overrideEmulateTouch(select.value === 'enabled');
} }
} }
}; };
...@@ -472,7 +472,7 @@ Emulation.SensorsView.PresetLocations = [ ...@@ -472,7 +472,7 @@ Emulation.SensorsView.PresetLocations = [
} }
]; ];
/** @type {!Array.<{title: string, value: !Array.<{title: string, orientation: !Emulation.DeviceOrientation}>}>} */ /** @type {!Array.<{title: string, value: !Array.<{title: string, orientation: string}>}>} */
Emulation.SensorsView.PresetOrientations = [{ Emulation.SensorsView.PresetOrientations = [{
title: 'Presets', title: 'Presets',
value: [ value: [
......
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* @implements {SDK.TargetManager.Observer}
* @unrestricted
*/
Emulation.MultitargetTouchModel = class {
constructor() {
this._touchEnabled = false;
this._touchMobile = false;
this._customTouchEnabled = false;
SDK.targetManager.observeTargets(this, SDK.Target.Capability.TouchEmulation);
}
/**
* @return {!Emulation.MultitargetTouchModel}
*/
static instance() {
if (!Emulation.MultitargetTouchModel._instance)
Emulation.MultitargetTouchModel._instance = new Emulation.MultitargetTouchModel();
return /** @type {!Emulation.MultitargetTouchModel} */ (Emulation.MultitargetTouchModel._instance);
}
/**
* @param {boolean} enabled
* @param {boolean} mobile
*/
setTouchEnabled(enabled, mobile) {
this._touchEnabled = enabled;
this._touchMobile = mobile;
this._updateAllTargets();
}
/**
* @param {boolean} enabled
*/
setCustomTouchEnabled(enabled) {
this._customTouchEnabled = enabled;
this._updateAllTargets();
}
_updateAllTargets() {
for (var target of SDK.targetManager.targets(SDK.Target.Capability.TouchEmulation))
this._applyToTarget(target);
}
/**
* @param {!SDK.Target} target
*/
_applyToTarget(target) {
var current = {enabled: this._touchEnabled, configuration: this._touchMobile ? 'mobile' : 'desktop'};
if (this._customTouchEnabled)
current = {enabled: true, configuration: 'mobile'};
var overlayModel = target.model(SDK.OverlayModel);
var inspectModeEnabled = overlayModel ? overlayModel.inspectModeEnabled() : false;
if (inspectModeEnabled)
current = {enabled: false, configuration: 'mobile'};
/**
* @suppressGlobalPropertiesCheck
*/
const injectedFunction = function() {
const touchEvents = ['ontouchstart', 'ontouchend', 'ontouchmove', 'ontouchcancel'];
var recepients = [window.__proto__, document.__proto__];
for (var i = 0; i < touchEvents.length; ++i) {
for (var j = 0; j < recepients.length; ++j) {
if (!(touchEvents[i] in recepients[j])) {
Object.defineProperty(
recepients[j], touchEvents[i], {value: null, writable: true, configurable: true, enumerable: true});
}
}
}
};
var symbol = Emulation.MultitargetTouchModel._symbol;
var previous = target[symbol] || {enabled: false, configuration: 'mobile', scriptId: ''};
if (previous.enabled === current.enabled && (!current.enabled || previous.configuration === current.configuration))
return;
if (previous.scriptId) {
target.pageAgent().removeScriptToEvaluateOnLoad(previous.scriptId);
target[symbol].scriptId = '';
}
target[symbol] = current;
target[symbol].scriptId = '';
if (current.enabled)
target.pageAgent().addScriptToEvaluateOnLoad('(' + injectedFunction.toString() + ')()', scriptAddedCallback);
/**
* @param {?Protocol.Error} error
* @param {string} scriptId
*/
function scriptAddedCallback(error, scriptId) {
(target[symbol] || {}).scriptId = error ? '' : scriptId;
}
target.emulationAgent().setTouchEmulationEnabled(current.enabled, current.configuration);
}
/**
* @param {!Common.Event} event
*/
_inspectModeToggled(event) {
var overlayModel = /** @type {!SDK.OverlayModel} */ (event.data);
this._applyToTarget(overlayModel.target());
}
/**
* @override
* @param {!SDK.Target} target
*/
targetAdded(target) {
var overlayModel = target.model(SDK.OverlayModel);
if (overlayModel)
overlayModel.addEventListener(SDK.OverlayModel.Events.InspectModeWillBeToggled, this._inspectModeToggled, this);
this._applyToTarget(target);
}
/**
* @override
* @param {!SDK.Target} target
*/
targetRemoved(target) {
var overlayModel = target.model(SDK.OverlayModel);
if (overlayModel) {
overlayModel.removeEventListener(
SDK.OverlayModel.Events.InspectModeWillBeToggled, this._inspectModeToggled, this);
}
}
};
Emulation.MultitargetTouchModel._symbol = Symbol('MultitargetTouchModel.symbol');
/** @type {?Emulation.MultitargetTouchModel} */
Emulation.MultitargetTouchModel._instance = null;
...@@ -154,12 +154,9 @@ ...@@ -154,12 +154,9 @@
"AdvancedApp.js", "AdvancedApp.js",
"EmulatedDevices.js", "EmulatedDevices.js",
"DevicesSettingsTab.js", "DevicesSettingsTab.js",
"DeviceOrientation.js",
"Geolocation.js",
"InspectedPagePlaceholder.js", "InspectedPagePlaceholder.js",
"MediaQueryInspector.js", "MediaQueryInspector.js",
"SensorsView.js", "SensorsView.js",
"TouchModel.js",
"DeviceModeModel.js", "DeviceModeModel.js",
"DeviceModeToolbar.js", "DeviceModeToolbar.js",
"DeviceModeView.js", "DeviceModeView.js",
......
...@@ -909,8 +909,6 @@ Main.BackendSettingsSync = class { ...@@ -909,8 +909,6 @@ Main.BackendSettingsSync = class {
constructor() { constructor() {
this._autoAttachSetting = Common.settings.moduleSetting('autoAttachToCreatedPages'); this._autoAttachSetting = Common.settings.moduleSetting('autoAttachToCreatedPages');
this._autoAttachSetting.addChangeListener(this._update, this); this._autoAttachSetting.addChangeListener(this._update, this);
this._disableJavascriptSetting = Common.settings.moduleSetting('javaScriptDisabled');
this._disableJavascriptSetting.addChangeListener(this._update, this);
SDK.targetManager.observeTargets(this, SDK.Target.Capability.Browser); SDK.targetManager.observeTargets(this, SDK.Target.Capability.Browser);
} }
...@@ -919,7 +917,6 @@ Main.BackendSettingsSync = class { ...@@ -919,7 +917,6 @@ Main.BackendSettingsSync = class {
*/ */
_updateTarget(target) { _updateTarget(target) {
target.pageAgent().setAutoAttachToCreatedPages(this._autoAttachSetting.get()); target.pageAgent().setAutoAttachToCreatedPages(this._autoAttachSetting.get());
target.emulationAgent().setScriptExecutionDisabled(this._disableJavascriptSetting.get());
} }
_update() { _update() {
......
...@@ -27,9 +27,9 @@ ...@@ -27,9 +27,9 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
/** /**
* @implements {SDK.TargetManager.Observer} * @implements {SDK.SDKModelObserver<!SDK.EmulationModel>}
* @unrestricted
*/ */
Main.RenderingOptionsView = class extends UI.VBox { Main.RenderingOptionsView = class extends UI.VBox {
constructor() { constructor() {
...@@ -67,16 +67,7 @@ Main.RenderingOptionsView = class extends UI.VBox { ...@@ -67,16 +67,7 @@ Main.RenderingOptionsView = class extends UI.VBox {
this._mediaSelect.addEventListener('change', this._mediaToggled.bind(this), false); this._mediaSelect.addEventListener('change', this._mediaToggled.bind(this), false);
this._mediaSelect.disabled = true; this._mediaSelect.disabled = true;
SDK.targetManager.observeTargets(this); SDK.targetManager.observeModels(SDK.EmulationModel, this);
}
/**
* @return {!Main.RenderingOptionsView}
*/
static instance() {
if (!Main.RenderingOptionsView._instanceObject)
Main.RenderingOptionsView._instanceObject = new Main.RenderingOptionsView();
return Main.RenderingOptionsView._instanceObject;
} }
/** /**
...@@ -92,34 +83,24 @@ Main.RenderingOptionsView = class extends UI.VBox { ...@@ -92,34 +83,24 @@ Main.RenderingOptionsView = class extends UI.VBox {
/** /**
* @override * @override
* @param {!SDK.Target} target * @param {!SDK.EmulationModel} emulationModel
*/ */
targetAdded(target) { modelAdded(emulationModel) {
if (this._mediaCheckbox.checked && target.hasBrowserCapability()) if (this._mediaCheckbox.checked)
this._applyPrintMediaOverride(target); emulationModel.emulateCSSMedia(this._mediaSelect.value);
} }
_mediaToggled() { _mediaToggled() {
this._mediaSelect.disabled = !this._mediaCheckbox.checked; this._mediaSelect.disabled = !this._mediaCheckbox.checked;
var targets = SDK.targetManager.targets(SDK.Target.Capability.Browser); var media = this._mediaCheckbox.checked ? this._mediaSelect.value : null;
for (var target of targets) for (var emulationModel of SDK.targetManager.models(SDK.EmulationModel))
this._applyPrintMediaOverride(target); emulationModel.emulateCSSMedia(media);
}
/**
* @param {!SDK.Target} target
*/
_applyPrintMediaOverride(target) {
target.emulationAgent().setEmulatedMedia(this._mediaCheckbox.checked ? this._mediaSelect.value : '');
var cssModel = target.model(SDK.CSSModel);
if (cssModel)
cssModel.mediaQueryResultChanged();
} }
/** /**
* @override * @override
* @param {!SDK.Target} target * @param {!SDK.EmulationModel} emulationModel
*/ */
targetRemoved(target) { modelRemoved(emulationModel) {
} }
}; };
...@@ -245,26 +245,6 @@ ...@@ -245,26 +245,6 @@
} }
] ]
}, },
{
"type": "setting",
"category": "Debugger",
"title": "Disable JavaScript",
"settingName": "javaScriptDisabled",
"settingType": "boolean",
"storageType": "session",
"order": 1,
"defaultValue": false,
"options": [
{
"value": true,
"title": "Disable JavaScript"
},
{
"value": false,
"title": "Enable JavaScript"
}
]
},
{ {
"type": "setting", "type": "setting",
"category": "DevTools", "category": "DevTools",
......
...@@ -130,7 +130,8 @@ Screencast.ScreencastView = class extends UI.VBox { ...@@ -130,7 +130,8 @@ Screencast.ScreencastView = class extends UI.VBox {
'jpeg', 80, Math.floor(Math.min(maxImageDimension, dimensions.width)), 'jpeg', 80, Math.floor(Math.min(maxImageDimension, dimensions.width)),
Math.floor(Math.min(maxImageDimension, dimensions.height)), undefined, this._screencastFrame.bind(this), Math.floor(Math.min(maxImageDimension, dimensions.height)), undefined, this._screencastFrame.bind(this),
this._screencastVisibilityChanged.bind(this)); this._screencastVisibilityChanged.bind(this));
Emulation.MultitargetTouchModel.instance().setCustomTouchEnabled(true); for (var emulationModel of SDK.targetManager.models(SDK.EmulationModel))
emulationModel.overrideEmulateTouch(true);
if (this._overlayModel) if (this._overlayModel)
this._overlayModel.setHighlighter(this); this._overlayModel.setHighlighter(this);
} }
...@@ -140,7 +141,8 @@ Screencast.ScreencastView = class extends UI.VBox { ...@@ -140,7 +141,8 @@ Screencast.ScreencastView = class extends UI.VBox {
return; return;
this._isCasting = false; this._isCasting = false;
this._screenCaptureModel.stopScreencast(); this._screenCaptureModel.stopScreencast();
Emulation.MultitargetTouchModel.instance().setCustomTouchEnabled(false); for (var emulationModel of SDK.targetManager.models(SDK.EmulationModel))
emulationModel.overrideEmulateTouch(false);
if (this._overlayModel) if (this._overlayModel)
this._overlayModel.setHighlighter(null); this._overlayModel.setHighlighter(null);
} }
......
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
SDK.EmulationModel = class extends SDK.SDKModel {
/**
* @param {!SDK.Target} target
*/
constructor(target) {
super(target);
this._emulationAgent = target.emulationAgent();
this._pageAgent = target.pageAgent();
this._deviceOrientationAgent = target.deviceOrientationAgent();
this._cssModel = target.model(SDK.CSSModel);
this._overlayModel = target.model(SDK.OverlayModel);
if (this._overlayModel)
this._overlayModel.addEventListener(SDK.OverlayModel.Events.InspectModeWillBeToggled, this._updateTouch, this);
var disableJavascriptSetting = Common.settings.moduleSetting('javaScriptDisabled');
disableJavascriptSetting.addChangeListener(
() => this._emulationAgent.setScriptExecutionDisabled(disableJavascriptSetting.get()));
if (disableJavascriptSetting.get())
this._emulationAgent.setScriptExecutionDisabled(true);
this._touchEnabled = false;
this._touchMobile = false;
this._customTouchEnabled = false;
this._touchConfiguration = {enabled: false, configuration: 'mobile', scriptId: ''};
}
/**
* @return {boolean}
*/
supportsDeviceEmulation() {
return this.target().hasAllCapabilities(SDK.Target.Capability.DeviceEmulation);
}
/**
* @param {?SDK.EmulationModel.Geolocation} geolocation
*/
emulateGeolocation(geolocation) {
if (!geolocation) {
this._emulationAgent.clearGeolocationOverride();
return;
}
if (geolocation.error) {
this._emulationAgent.setGeolocationOverride();
} else {
this._emulationAgent.setGeolocationOverride(
geolocation.latitude, geolocation.longitude, SDK.EmulationModel.Geolocation.DefaultMockAccuracy);
}
}
/**
* @param {?SDK.EmulationModel.DeviceOrientation} deviceOrientation
*/
emulateDeviceOrientation(deviceOrientation) {
if (deviceOrientation) {
this._deviceOrientationAgent.setDeviceOrientationOverride(
deviceOrientation.alpha, deviceOrientation.beta, deviceOrientation.gamma);
} else {
this._deviceOrientationAgent.clearDeviceOrientationOverride();
}
}
/**
* @param {?string} media
*/
emulateCSSMedia(media) {
this._emulationAgent.setEmulatedMedia(media || '');
if (this._cssModel)
this._cssModel.mediaQueryResultChanged();
}
/**
* @param {number} rate
*/
setCPUThrottlingRate(rate) {
this._emulationAgent.setCPUThrottlingRate(rate);
}
/**
* @param {boolean} enabled
* @param {boolean} mobile
*/
emulateTouch(enabled, mobile) {
this._touchEnabled = enabled;
this._touchMobile = mobile;
this._updateTouch();
}
/**
* @param {boolean} enabled
*/
overrideEmulateTouch(enabled) {
this._customTouchEnabled = enabled;
this._updateTouch();
}
_updateTouch() {
var configuration = {
enabled: this._touchEnabled,
configuration: this._touchMobile ? 'mobile' : 'desktop',
scriptId: ''
};
if (this._customTouchEnabled)
configuration = {enabled: true, configuration: 'mobile', scriptId: ''};
if (this._overlayModel && this._overlayModel.inspectModeEnabled())
configuration = {enabled: false, configuration: 'mobile', scriptId: ''};
/**
* @suppressGlobalPropertiesCheck
*/
const injectedFunction = function() {
const touchEvents = ['ontouchstart', 'ontouchend', 'ontouchmove', 'ontouchcancel'];
var recepients = [window.__proto__, document.__proto__];
for (var i = 0; i < touchEvents.length; ++i) {
for (var j = 0; j < recepients.length; ++j) {
if (!(touchEvents[i] in recepients[j])) {
Object.defineProperty(
recepients[j], touchEvents[i], {value: null, writable: true, configurable: true, enumerable: true});
}
}
}
};
if (!this._touchConfiguration.enabled && !configuration.enabled)
return;
if (this._touchConfiguration.enabled && configuration.enabled &&
this._touchConfiguration.configuration === configuration.configuration)
return;
if (this._touchConfiguration.scriptId)
this._pageAgent.removeScriptToEvaluateOnLoad(this._touchConfiguration.scriptId);
this._touchConfiguration = configuration;
if (configuration.enabled) {
this._pageAgent.addScriptToEvaluateOnLoad('(' + injectedFunction.toString() + ')()', (error, scriptId) => {
this._touchConfiguration.scriptId = error ? '' : scriptId;
});
}
this._emulationAgent.setTouchEmulationEnabled(configuration.enabled, configuration.configuration);
}
};
SDK.SDKModel.register(SDK.EmulationModel, SDK.Target.Capability.Emulation, true);
SDK.EmulationModel.Geolocation = class {
/**
* @param {number} latitude
* @param {number} longitude
* @param {boolean} error
*/
constructor(latitude, longitude, error) {
this.latitude = latitude;
this.longitude = longitude;
this.error = error;
}
/**
* @return {!SDK.EmulationModel.Geolocation}
*/
static parseSetting(value) {
if (value) {
var splitError = value.split(':');
if (splitError.length === 2) {
var splitPosition = splitError[0].split('@');
if (splitPosition.length === 2) {
return new SDK.EmulationModel.Geolocation(
parseFloat(splitPosition[0]), parseFloat(splitPosition[1]), splitError[1]);
}
}
}
return new SDK.EmulationModel.Geolocation(0, 0, false);
}
/**
* @param {string} latitudeString
* @param {string} longitudeString
* @param {string} errorStatus
* @return {?SDK.EmulationModel.Geolocation}
*/
static parseUserInput(latitudeString, longitudeString, errorStatus) {
if (!latitudeString && !longitudeString)
return null;
var isLatitudeValid = SDK.EmulationModel.Geolocation.latitudeValidator(latitudeString);
var isLongitudeValid = SDK.EmulationModel.Geolocation.longitudeValidator(longitudeString);
if (!isLatitudeValid && !isLongitudeValid)
return null;
var latitude = isLatitudeValid ? parseFloat(latitudeString) : -1;
var longitude = isLongitudeValid ? parseFloat(longitudeString) : -1;
return new SDK.EmulationModel.Geolocation(latitude, longitude, !!errorStatus);
}
/**
* @param {string} value
* @return {boolean}
*/
static latitudeValidator(value) {
var numValue = parseFloat(value);
return /^([+-]?[\d]+(\.\d+)?|[+-]?\.\d+)$/.test(value) && numValue >= -90 && numValue <= 90;
}
/**
* @param {string} value
* @return {boolean}
*/
static longitudeValidator(value) {
var numValue = parseFloat(value);
return /^([+-]?[\d]+(\.\d+)?|[+-]?\.\d+)$/.test(value) && numValue >= -180 && numValue <= 180;
}
/**
* @return {string}
*/
toSetting() {
return (typeof this.latitude === 'number' && typeof this.longitude === 'number' && typeof this.error === 'string') ?
this.latitude + '@' + this.longitude + ':' + this.error :
'';
}
};
SDK.EmulationModel.Geolocation.DefaultMockAccuracy = 150;
SDK.EmulationModel.DeviceOrientation = class {
/**
* @param {number} alpha
* @param {number} beta
* @param {number} gamma
*/
constructor(alpha, beta, gamma) {
this.alpha = alpha;
this.beta = beta;
this.gamma = gamma;
}
/**
* @return {!SDK.EmulationModel.DeviceOrientation}
*/
static parseSetting(value) {
if (value) {
var jsonObject = JSON.parse(value);
return new SDK.EmulationModel.DeviceOrientation(jsonObject.alpha, jsonObject.beta, jsonObject.gamma);
}
return new SDK.EmulationModel.DeviceOrientation(0, 0, 0);
}
/**
* @return {?SDK.EmulationModel.DeviceOrientation}
*/
static parseUserInput(alphaString, betaString, gammaString) {
if (!alphaString && !betaString && !gammaString)
return null;
var isAlphaValid = SDK.EmulationModel.DeviceOrientation.validator(alphaString);
var isBetaValid = SDK.EmulationModel.DeviceOrientation.validator(betaString);
var isGammaValid = SDK.EmulationModel.DeviceOrientation.validator(gammaString);
if (!isAlphaValid && !isBetaValid && !isGammaValid)
return null;
var alpha = isAlphaValid ? parseFloat(alphaString) : -1;
var beta = isBetaValid ? parseFloat(betaString) : -1;
var gamma = isGammaValid ? parseFloat(gammaString) : -1;
return new SDK.EmulationModel.DeviceOrientation(alpha, beta, gamma);
}
/**
* @param {string} value
* @return {boolean}
*/
static validator(value) {
return /^([+-]?[\d]+(\.\d+)?|[+-]?\.\d+)$/.test(value);
}
/**
* @return {string}
*/
toSetting() {
return JSON.stringify(this);
}
};
...@@ -208,14 +208,15 @@ SDK.Target.Capability = { ...@@ -208,14 +208,15 @@ SDK.Target.Capability = {
Target: 1 << 5, Target: 1 << 5,
ScreenCapture: 1 << 6, ScreenCapture: 1 << 6,
Tracing: 1 << 7, Tracing: 1 << 7,
TouchEmulation: 1 << 8, Emulation: 1 << 8,
Security: 1 << 9, Security: 1 << 9,
Input: 1 << 10, Input: 1 << 10,
Inspector: 1 << 11, Inspector: 1 << 11,
DeviceEmulation: 1 << 12,
None: 0, None: 0,
AllForTests: (1 << 12) - 1 AllForTests: (1 << 13) - 1
}; };
/** /**
......
...@@ -333,8 +333,9 @@ SDK.TargetManager = class extends Common.Object { ...@@ -333,8 +333,9 @@ SDK.TargetManager = class extends Common.Object {
var capabilities = SDK.Target.Capability.Browser | SDK.Target.Capability.DOM | SDK.Target.Capability.JS | var capabilities = SDK.Target.Capability.Browser | SDK.Target.Capability.DOM | SDK.Target.Capability.JS |
SDK.Target.Capability.Log | SDK.Target.Capability.Network | SDK.Target.Capability.Target | SDK.Target.Capability.Log | SDK.Target.Capability.Network | SDK.Target.Capability.Target |
SDK.Target.Capability.ScreenCapture | SDK.Target.Capability.Tracing | SDK.Target.Capability.TouchEmulation | SDK.Target.Capability.ScreenCapture | SDK.Target.Capability.Tracing | SDK.Target.Capability.Emulation |
SDK.Target.Capability.Security | SDK.Target.Capability.Input | SDK.Target.Capability.Inspector; SDK.Target.Capability.Security | SDK.Target.Capability.Input | SDK.Target.Capability.Inspector |
SDK.Target.Capability.DeviceEmulation;
if (Runtime.queryParam('isSharedWorker')) { if (Runtime.queryParam('isSharedWorker')) {
capabilities = SDK.Target.Capability.Browser | SDK.Target.Capability.Log | SDK.Target.Capability.Network | capabilities = SDK.Target.Capability.Browser | SDK.Target.Capability.Log | SDK.Target.Capability.Network |
SDK.Target.Capability.Target | SDK.Target.Capability.Inspector; SDK.Target.Capability.Target | SDK.Target.Capability.Inspector;
...@@ -440,7 +441,7 @@ SDK.ChildTargetManager = class { ...@@ -440,7 +441,7 @@ SDK.ChildTargetManager = class {
if (type === 'iframe') { if (type === 'iframe') {
return SDK.Target.Capability.Browser | SDK.Target.Capability.DOM | SDK.Target.Capability.JS | return SDK.Target.Capability.Browser | SDK.Target.Capability.DOM | SDK.Target.Capability.JS |
SDK.Target.Capability.Log | SDK.Target.Capability.Network | SDK.Target.Capability.Target | SDK.Target.Capability.Log | SDK.Target.Capability.Network | SDK.Target.Capability.Target |
SDK.Target.Capability.Tracing | SDK.Target.Capability.TouchEmulation | SDK.Target.Capability.Input; SDK.Target.Capability.Tracing | SDK.Target.Capability.Emulation | SDK.Target.Capability.Input;
} }
if (type === 'node') if (type === 'node')
return SDK.Target.Capability.JS; return SDK.Target.Capability.JS;
......
...@@ -59,6 +59,26 @@ ...@@ -59,6 +59,26 @@
"settingType": "boolean", "settingType": "boolean",
"defaultValue": false "defaultValue": false
}, },
{
"type": "setting",
"category": "Debugger",
"title": "Disable JavaScript",
"settingName": "javaScriptDisabled",
"settingType": "boolean",
"storageType": "session",
"order": 1,
"defaultValue": false,
"options": [
{
"value": true,
"title": "Disable JavaScript"
},
{
"value": false,
"title": "Enable JavaScript"
}
]
},
{ {
"type": "setting", "type": "setting",
"category": "Debugger", "category": "Debugger",
...@@ -162,6 +182,7 @@ ...@@ -162,6 +182,7 @@
"DOMDebuggerModel.js", "DOMDebuggerModel.js",
"DOMModel.js", "DOMModel.js",
"DebuggerModel.js", "DebuggerModel.js",
"EmulationModel.js",
"LayerTreeBase.js", "LayerTreeBase.js",
"LogModel.js", "LogModel.js",
"ServiceWorkerManager.js", "ServiceWorkerManager.js",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment