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 2 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
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
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: 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