Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: remove disableDeviceEmulation flag #8289

Merged
merged 4 commits into from
Apr 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ instance with an open debugging port.

Lighthouse can run against a real mobile device. You can follow the [Remote Debugging on Android (Legacy Workflow)](https://developer.chrome.com/devtools/docs/remote-debugging-legacy) up through step 3.3, but the TL;DR is install & run adb, enable USB debugging, then port forward 9222 from the device to the machine with Lighthouse.

You'll likely want to use the CLI flags `--disable-device-emulation --throttling.cpuSlowdownMultiplier`.
You'll likely want to use the CLI flags `--emulated-form-factor=none --throttling.cpuSlowdownMultiplier=1` to disable any additional emulation.

```sh
$ adb kill-server
Expand All @@ -131,7 +131,7 @@ $ adb devices -l

$ adb forward tcp:9222 localabstract:chrome_devtools_remote

$ lighthouse --port=9222 --disable-device-emulation --throttling.cpuSlowdownMultiplier=1 https://example.com
$ lighthouse --port=9222 --emulated-form-factor=none --throttling.cpuSlowdownMultiplier=1 https://example.com
```

## Lighthouse as trace processor
Expand Down
2 changes: 1 addition & 1 deletion docs/understanding-results.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ An object containing information about the configuration used by Lighthouse.
},
"gatherMode": false,
"disableStorageReset": false,
"disableDeviceEmulation": false,
"emulatedFormFactor": "mobile",
"blockedUrlPatterns": null,
"additionalTraceCategories": null,
"extraHeaders": null,
Expand Down
5 changes: 2 additions & 3 deletions lighthouse-cli/cli-flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function getFlags(manualArgv) {
'lighthouse <url> --output=json --output-path=./report.json --save-assets',
'Save trace, screenshots, and named JSON report.')
.example(
'lighthouse <url> --disable-device-emulation --throttling-method=provided',
'lighthouse <url> --emulated-form-factor=none --throttling-method=provided',
'Disable device emulation and all throttling')
.example(
'lighthouse <url> --chrome-flags="--window-size=412,660"',
Expand Down Expand Up @@ -70,7 +70,6 @@ function getFlags(manualArgv) {
'blocked-url-patterns': 'Block any network requests to the specified URL patterns',
'disable-storage-reset':
'Disable clearing the browser cache and other storage APIs before a run',
'disable-device-emulation': 'Disable all device form factor emulation. Deprecated: use --emulated-form-factor=none instead',
'emulated-form-factor': 'Controls the emulated device form factor (mobile vs. desktop) if not disabled',
'throttling-method': 'Controls throttling method',
'throttling.rttMs': 'Controls simulated network RTT (TCP layer)',
Expand Down Expand Up @@ -123,7 +122,7 @@ function getFlags(manualArgv) {

// boolean values
.boolean([
'disable-storage-reset', 'disable-device-emulation', 'save-assets', 'list-all-audits',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nbd, just the flag :)

'disable-storage-reset', 'save-assets', 'list-all-audits',
'list-trace-categories', 'view', 'verbose', 'quiet', 'help', 'print-config',
])
.choices('output', printer.getValidOutputOptions())
Expand Down
2 changes: 0 additions & 2 deletions lighthouse-cli/test/cli/__snapshots__/index-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1194,7 +1194,6 @@ Object {
"auditMode": false,
"blockedUrlPatterns": null,
"channel": "cli",
"disableDeviceEmulation": false,
"disableStorageReset": false,
"emulatedFormFactor": "mobile",
"extraHeaders": null,
Expand Down Expand Up @@ -1324,7 +1323,6 @@ Object {
"auditMode": true,
"blockedUrlPatterns": null,
"channel": "cli",
"disableDeviceEmulation": false,
"disableStorageReset": false,
"emulatedFormFactor": "mobile",
"extraHeaders": null,
Expand Down
1 change: 0 additions & 1 deletion lighthouse-core/config/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ const defaultSettings = {
auditMode: false,
gatherMode: false,
disableStorageReset: false,
disableDeviceEmulation: false,
emulatedFormFactor: 'mobile',
channel: 'node',

Expand Down
10 changes: 4 additions & 6 deletions lighthouse-core/gather/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -1406,12 +1406,10 @@ class Driver {
* @return {Promise<void>}
*/
async beginEmulation(settings) {
if (!settings.disableDeviceEmulation) {
if (settings.emulatedFormFactor === 'mobile') {
await emulation.enableNexus5X(this);
} else if (settings.emulatedFormFactor === 'desktop') {
await emulation.enableDesktop(this);
}
if (settings.emulatedFormFactor === 'mobile') {
await emulation.enableNexus5X(this);
} else if (settings.emulatedFormFactor === 'desktop') {
await emulation.enableDesktop(this);
}

await this.setThrottling(settings, {useThrottling: true});
Expand Down
1 change: 0 additions & 1 deletion lighthouse-core/lib/sentry.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ function init(opts) {

const context = Object.assign({
url: opts.url,
deviceEmulation: !opts.flags.disableDeviceEmulation,
emulatedFormFactor: opts.flags.emulatedFormFactor,
throttlingMethod: opts.flags.throttlingMethod,
}, opts.flags.throttling);
Expand Down
6 changes: 2 additions & 4 deletions lighthouse-core/report/html/renderer/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,10 +400,8 @@ class Util {
}

let deviceEmulation = 'No emulation';
if (!settings.disableDeviceEmulation) {
if (settings.emulatedFormFactor === 'mobile') deviceEmulation = 'Emulated Nexus 5X';
if (settings.emulatedFormFactor === 'desktop') deviceEmulation = 'Emulated Desktop';
}
if (settings.emulatedFormFactor === 'mobile') deviceEmulation = 'Emulated Nexus 5X';
if (settings.emulatedFormFactor === 'desktop') deviceEmulation = 'Emulated Desktop';

return {
deviceEmulation,
Expand Down
6 changes: 3 additions & 3 deletions lighthouse-core/test/config/config-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -581,16 +581,16 @@ describe('Config', () => {
extends: 'lighthouse:full',
settings: {
disableStorageReset: true,
disableDeviceEmulation: false,
emulatedFormFactor: 'mobile',
},
},
{disableDeviceEmulation: true}
{emulatedFormFactor: 'desktop'}
);

assert.ok(config, 'failed to generate config');
assert.ok(typeof config.settings.maxWaitForLoad === 'number', 'missing setting from default');
assert.ok(config.settings.disableStorageReset, 'missing setting from extension config');
assert.ok(config.settings.disableDeviceEmulation, 'missing setting from flags');
assert.ok(config.settings.emulatedFormFactor === 'desktop', 'missing setting from flags');
});

it('inherits default settings when undefined', () => {
Expand Down
29 changes: 0 additions & 29 deletions lighthouse-core/test/gather/gather-runner-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,35 +231,6 @@ describe('GatherRunner', function() {
});
});

it('stops device emulation when disableDeviceEmulation flag is true', () => {
const tests = {
calledDeviceEmulation: false,
calledNetworkEmulation: false,
calledCpuEmulation: false,
};
const createEmulationCheck = variable => () => {
tests[variable] = true;
return true;
};
const driver = getMockedEmulationDriver(
createEmulationCheck('calledDeviceEmulation', false),
createEmulationCheck('calledNetworkEmulation', true),
createEmulationCheck('calledCpuEmulation', true)
);

return GatherRunner.setupDriver(driver, {
settings: {
disableDeviceEmulation: true,
throttlingMethod: 'devtools',
throttling: {},
},
}).then(_ => {
assert.equal(tests.calledDeviceEmulation, false);
assert.equal(tests.calledNetworkEmulation, true);
assert.equal(tests.calledCpuEmulation, true);
});
});

it('uses correct emulation form factor', async () => {
let emulationParams;
const driver = getMockedEmulationDriver(
Expand Down
1 change: 0 additions & 1 deletion lighthouse-core/test/lib/proto-preprocessor-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ describe('processing for proto', () => {
},
'gatherMode': false,
'disableStorageReset': false,
'disableDeviceEmulation': false,
'emulatedFormFactor': 'mobile',
'locale': 'en-US',
'blockedUrlPatterns': null,
Expand Down
1 change: 0 additions & 1 deletion lighthouse-core/test/lib/sentry-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ describe('Sentry', () => {
expect(raven.mergeContext.mock.calls[0][0]).toEqual({
extra: {
url: 'http://example.com',
deviceEmulation: true,
emulatedFormFactor: 'desktop',
throttlingMethod: 'devtools',
},
Expand Down
2 changes: 0 additions & 2 deletions lighthouse-core/test/report/html/renderer/util-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@ describe('util helpers', () => {

it('builds device emulation string', () => {
const get = opts => Util.getEmulationDescriptions(opts).deviceEmulation;
assert.equal(get({disableDeviceEmulation: true}), 'No emulation');
assert.equal(get({disableDeviceEmulation: false}), 'No emulation');
assert.equal(get({emulatedFormFactor: 'none'}), 'No emulation');
assert.equal(get({emulatedFormFactor: 'mobile'}), 'Emulated Nexus 5X');
assert.equal(get({emulatedFormFactor: 'desktop'}), 'Emulated Desktop');
Expand Down
1 change: 0 additions & 1 deletion lighthouse-core/test/results/artifacts/artifacts.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"auditMode": false,
"gatherMode": "lighthouse-core/test/results/artifacts",
"disableStorageReset": false,
"disableDeviceEmulation": false,
"emulatedFormFactor": "mobile",
"channel": "cli",
"locale": "en-US",
Expand Down
3 changes: 1 addition & 2 deletions lighthouse-core/test/results/sample_v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -3049,7 +3049,6 @@
"auditMode": true,
"gatherMode": false,
"disableStorageReset": false,
"disableDeviceEmulation": false,
"emulatedFormFactor": "mobile",
"channel": "cli",
"locale": "en-US",
Expand Down Expand Up @@ -5509,4 +5508,4 @@
}
},
"stackPacks": []
}
}
4 changes: 2 additions & 2 deletions lighthouse-core/test/runner-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ describe('Runner', () => {
});

it('-A throws if the settings change', async () => {
const settings = {auditMode: artifactsPath, disableDeviceEmulation: true};
const settings = {auditMode: artifactsPath, emulatedFormFactor: 'desktop'};
const opts = {config: generateConfig(settings), driverMock};
try {
await Runner.run(null, opts);
Expand All @@ -110,7 +110,7 @@ describe('Runner', () => {
});

it('-A throws if the URL changes', async () => {
const settings = {auditMode: artifactsPath, disableDeviceEmulation: true};
const settings = {auditMode: artifactsPath, emulatedFormFactor: 'desktop'};
const opts = {url: 'https://differenturl.com', config: generateConfig(settings), driverMock};
try {
await Runner.run(null, opts);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"devtools": "bash lighthouse-core/scripts/roll-to-devtools.sh",
"compile-devtools": "bash lighthouse-core/scripts/compile-against-devtools.sh",
"chrome": "node lighthouse-core/scripts/manual-chrome-launcher.js",
"fast": "yarn start --disable-device-emulation --throttlingMethod=provided",
"fast": "yarn start --emulated-form-factor=none --throttlingMethod=provided",
"deploy-viewer": "yarn build-viewer --deploy",
"bundlesize": "bundlesize",
"timing-trace": "node lighthouse-core/scripts/generate-timing-trace.js",
Expand Down
3 changes: 1 addition & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ Options:
--version Show version number [boolean]
--blocked-url-patterns Block any network requests to the specified URL patterns [array]
--disable-storage-reset Disable clearing the browser cache and other storage APIs before a run [boolean]
--disable-device-emulation Disable all device form factor emulation. Deprecated: use --emulated-form-factor=none instead [boolean]
--throttling-method Controls throttling method [choices: "devtools", "provided", "simulate"]
--throttling.rttMs Controls simulated network RTT (TCP layer)
--throttling.throughputKbps Controls simulated network download throughput
Expand All @@ -106,7 +105,7 @@ Examples:
lighthouse <url> --config-path=./myconfig.js Runs Lighthouse with your own configuration: custom audits, report
generation, etc.
lighthouse <url> --output=json --output-path=./report.json --save-assets Save trace, devtoolslog, and named JSON report.
lighthouse <url> --disable-device-emulation Disable device emulation and all throttling.
lighthouse <url> --emulated-form-factor=none Disable device emulation and all throttling.
--throttling-method=provided
lighthouse <url> --chrome-flags="--window-size=412,660" Launch Chrome with a specific window size
lighthouse <url> --quiet --chrome-flags="--headless" Launch Headless Chrome, turn off logging
Expand Down
2 changes: 0 additions & 2 deletions types/externs.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ declare global {
gatherMode?: boolean | string;
/** Flag indicating that the browser storage should not be reset for the audit. */
disableStorageReset?: boolean;
/** Flag indicating that there shouldn't be any emulation during the run. */
disableDeviceEmulation?: boolean;
/** The form factor the emulation should use. */
emulatedFormFactor?: 'mobile'|'desktop'|'none';
/** The method used to throttle the network. */
Expand Down