-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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 some trivial uses of WebInspector #6090
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,6 @@ | |
*/ | ||
'use strict'; | ||
|
||
const NetworkManager = require('./web-inspector').NetworkManager; | ||
const NetworkRequest = require('./network-request'); | ||
const EventEmitter = require('events').EventEmitter; | ||
const log = require('lighthouse-logger'); | ||
|
@@ -47,10 +46,6 @@ class NetworkRecorder extends EventEmitter { | |
return super.once(event, listener); | ||
} | ||
|
||
get EventTypes() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
return NetworkManager.Events; | ||
} | ||
|
||
isIdle() { | ||
return !!this._getActiveIdlePeriod(0); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,10 +32,10 @@ module.exports = (function() { | |
|
||
global.CSSAgent = {}; | ||
global.CSSAgent.StyleSheetOrigin = { | ||
INJECTED: 'injected', | ||
USER_AGENT: 'user-agent', | ||
INSPECTOR: 'inspector', | ||
REGULAR: 'regular', | ||
Injected: 'injected', | ||
UserAgent: 'user-agent', | ||
Inspector: 'inspector', | ||
Regular: 'regular', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these shouldn't have been all caps (see e.g. https://github.com/ChromeDevTools/devtools-frontend/blob/51d3d758c57dc51d1864b3003de1fdda82963623/front_end/sdk/CSSRule.js#L70). We only touch the code that checks if a style was injected or came from the user-agent, but unsure if that was affecting the output of our font-size code... |
||
}; | ||
|
||
global.CSS = {}; | ||
|
@@ -45,110 +45,29 @@ module.exports = (function() { | |
// See https://github.com/GoogleChrome/lighthouse/issues/73 | ||
const _setImmediate = global.setImmediate; | ||
|
||
global.Runtime = global.Runtime || {}; | ||
global.Runtime.experiments = global.Runtime.experiments || {}; | ||
// DevTools runtime doesn't know about some experiments that DTM looks for | ||
// To avoid exceptions, we assume all experiments are disabled | ||
global.Runtime.experiments.isEnabled = (_ => false); | ||
|
||
const _queryParam = global.Runtime.queryParam; | ||
global.Runtime.queryParam = function(arg) { | ||
switch (arg) { | ||
case 'remoteFrontend': | ||
return false; | ||
case 'ws': | ||
return false; | ||
default: { | ||
if (_queryParam) { | ||
return _queryParam.call(global.Runtime, arg); | ||
} | ||
throw new Error('Mock queryParam case not implemented.'); | ||
} | ||
} | ||
}; | ||
|
||
global.TreeElement = {}; | ||
global.WorkerRuntime = {}; | ||
|
||
global.Protocol = { | ||
Agents() {}, | ||
}; | ||
|
||
global.WebInspector = {}; | ||
const WebInspector = global.WebInspector; | ||
WebInspector._moduleSettings = { | ||
cacheDisabled: { | ||
addChangeListener() {}, | ||
get() { | ||
return false; | ||
}, | ||
}, | ||
monitoringXHREnabled: { | ||
addChangeListener() {}, | ||
get() { | ||
return false; | ||
}, | ||
}, | ||
showNativeFunctionsInJSProfile: { | ||
addChangeListener() {}, | ||
get() { | ||
return true; | ||
}, | ||
}, | ||
}; | ||
WebInspector.moduleSetting = function(settingName) { | ||
return this._moduleSettings[settingName]; | ||
}; | ||
|
||
// Shared Dependencies | ||
require('chrome-devtools-frontend/front_end/common/Object.js'); | ||
require('chrome-devtools-frontend/front_end/common/ParsedURL.js'); | ||
require('chrome-devtools-frontend/front_end/common/UIString.js'); | ||
require('chrome-devtools-frontend/front_end/common/SegmentedRange.js'); | ||
require('chrome-devtools-frontend/front_end/platform/utilities.js'); | ||
require('chrome-devtools-frontend/front_end/sdk/Target.js'); | ||
require('chrome-devtools-frontend/front_end/sdk/TargetManager.js'); | ||
|
||
// Dependencies for timeline-model | ||
WebInspector.targetManager = { | ||
observeTargets() { }, | ||
addEventListener() { }, | ||
}; | ||
WebInspector.settings = { | ||
createSetting() { | ||
return { | ||
get() { | ||
return false; | ||
}, | ||
addChangeListener() {}, | ||
}; | ||
}, | ||
}; | ||
WebInspector.console = { | ||
error() {}, | ||
}; | ||
WebInspector.VBox = function() {}; | ||
WebInspector.HBox = function() {}; | ||
WebInspector.ViewportDataGrid = function() {}; | ||
WebInspector.ViewportDataGridNode = function() {}; | ||
global.WorkerRuntime.Worker = function() {}; | ||
|
||
// used for streaming json parsing | ||
require('chrome-devtools-frontend/front_end/common/TextUtils.js'); | ||
require('chrome-devtools-frontend/front_end/timeline/TimelineLoader.js'); | ||
|
||
// Mock for WebInspector code that writes to console. | ||
WebInspector.ConsoleMessage = function() {}; | ||
WebInspector.ConsoleMessage.MessageSource = { | ||
Network: 'network', | ||
}; | ||
WebInspector.ConsoleMessage.MessageLevel = { | ||
Log: 'log', | ||
}; | ||
WebInspector.ConsoleMessage.MessageType = { | ||
Log: 'log', | ||
}; | ||
|
||
// Dependencies for effective CSS rule calculation. | ||
require('chrome-devtools-frontend/front_end/common/TextRange.js'); | ||
require('chrome-devtools-frontend/front_end/sdk/CSSMatchedStyles.js'); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The values that are compared against these are typed to only be one of these values, so really no point in bringing it in just for these three constants.