Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
3848575
remove network record dependency
patrickhulce Jun 8, 2018
58e7c51
fix byte-efficiency-audit
patrickhulce Jun 8, 2018
f35c56c
SUPER WIP
patrickhulce Jun 8, 2018
ade9def
fix tests
patrickhulce Jun 8, 2018
05194ea
fix tests
patrickhulce Jun 8, 2018
dd11851
golden LHR diffs
patrickhulce Jun 8, 2018
5988b11
remove commented code
patrickhulce Jun 11, 2018
1c16232
more tests
patrickhulce Jun 11, 2018
aecb428
more feedback
patrickhulce Jun 13, 2018
432b989
dump more of WebInspector
patrickhulce Jun 13, 2018
0324bc0
fix resource category
patrickhulce Jun 13, 2018
c5db54d
Merge branch 'master' into standardize_network_req_api
patrickhulce Jun 13, 2018
5836b4c
merge conflicts
patrickhulce Jun 13, 2018
cee1f0e
cleanup ts-nocheck files
patrickhulce Jun 13, 2018
4212ab6
fix mixed content
patrickhulce Jun 13, 2018
7634cf8
typo
patrickhulce Jun 14, 2018
21fe6df
feedback
patrickhulce Jun 14, 2018
1f0ac70
Merge branch 'master' into standardize_network_req_api
patrickhulce Jun 15, 2018
915449f
remove unused portions of ResourceType
patrickhulce Jun 18, 2018
95551ee
Merge branch 'master' into standardize_network_req_api
patrickhulce Jun 18, 2018
92e8abf
match two subtle DT behaviors
patrickhulce Jun 18, 2018
b831cbb
more DT behavior matching
patrickhulce Jun 19, 2018
911a268
Merge branch 'master' into standardize_network_req_api
patrickhulce Jun 19, 2018
d11d2e7
update lantern expectations
patrickhulce Jun 19, 2018
a2015af
feedback
patrickhulce Jun 19, 2018
e5bea12
more feedback
patrickhulce Jun 19, 2018
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
Prev Previous commit
Next Next commit
dump more of WebInspector
  • Loading branch information
patrickhulce committed Jun 13, 2018
commit 432b98998bcf172a0f2b7a1628e428da89113616
125 changes: 1 addition & 124 deletions lighthouse-core/lib/web-inspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,67 +100,13 @@ module.exports = (function() {
return this._moduleSettings[settingName];
};

// Enum from chromium//src/third_party/WebKit/Source/core/loader/MixedContentChecker.h
global.NetworkAgent = {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎉 🎈 🎉

RequestMixedContentType: {
Blockable: 'blockable',
OptionallyBlockable: 'optionally-blockable',
None: 'none',
},
BlockedReason: {
CSP: 'csp',
MixedContent: 'mixed-content',
Origin: 'origin',
Inspector: 'inspector',
Other: 'other',
},
InitiatorType: {
Other: 'other',
Parser: 'parser',
Redirect: 'redirect',
Script: 'script',
},
};

// Enum from SecurityState enum in protocol's Security domain
global.SecurityAgent = {
SecurityState: {
Unknown: 'unknown',
Neutral: 'neutral',
Insecure: 'insecure',
Warning: 'warning',
Secure: 'secure',
Info: 'info',
},
};
// From https://chromium.googlesource.com/chromium/src/third_party/WebKit/Source/devtools/+/master/protocol.json#93
global.PageAgent = {
ResourceType: {
Document: 'document',
Stylesheet: 'stylesheet',
Image: 'image',
Media: 'media',
Font: 'font',
Script: 'script',
TextTrack: 'texttrack',
XHR: 'xhr',
Fetch: 'fetch',
EventSource: 'eventsource',
WebSocket: 'websocket',
Manifest: 'manifest',
Other: 'other',
},
};
// Dependencies for network-recorder
// 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/ResourceType.js');
require('chrome-devtools-frontend/front_end/common/UIString.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');
require('chrome-devtools-frontend/front_end/sdk/NetworkManager.js');
require('chrome-devtools-frontend/front_end/sdk/NetworkRequest.js');

// Dependencies for timeline-model
WebInspector.targetManager = {
Expand Down Expand Up @@ -226,78 +172,9 @@ module.exports = (function() {
Log: 'log',
};

// Mock NetworkLog
WebInspector.NetworkLog = function(target) {
this._requests = new Map();
target.networkManager.addEventListener(
WebInspector.NetworkManager.Events.RequestStarted, this._onRequestStarted, this);
};

WebInspector.NetworkLog.prototype = {
requestForURL: function(url) {
return this._requests.get(url) || null;
},

_onRequestStarted: function(event) {
const request = event.data;
if (this._requests.has(request.url)) {
return;
}
this._requests.set(request.url, request);
},
};

// Dependencies for color parsing.
require('chrome-devtools-frontend/front_end/common/Color.js');

// Monkey patch update so we don't lose request information
// TODO: Remove when we update to a devtools version that has isLinkPreload
const Dispatcher = WebInspector.NetworkDispatcher;
const origUpdateRequest = Dispatcher.prototype._updateNetworkRequestWithRequest;
Dispatcher.prototype._updateNetworkRequestWithRequest = function(netRecord, request) {
origUpdateRequest.apply(this, arguments); // eslint-disable-line
netRecord.isLinkPreload = Boolean(request.isLinkPreload);
netRecord._isLinkPreload = Boolean(request.isLinkPreload);
};

/**
* Creates a new WebInspector NetworkManager using a mocked Target.
* @return {!WebInspector.NetworkManager}
*/
WebInspector.NetworkManager.createWithFakeTarget = function() {
// Mocked-up WebInspector Target for NetworkManager
const fakeNetworkAgent = {
enable() {},
getResponseBody() {
throw new Error('Use driver.getRequestContent() for network request content');
},
};
const fakeConsoleModel = {
addMessage() {},
target() {},
};
const fakeTarget = {
_modelByConstructor: new Map(),
get consoleModel() {
return fakeConsoleModel;
},
networkAgent() {
return fakeNetworkAgent;
},
registerNetworkDispatcher() { },
model() { },
};

fakeTarget.networkManager = new WebInspector.NetworkManager(fakeTarget);
fakeTarget.networkLog = new WebInspector.NetworkLog(fakeTarget);

WebInspector.NetworkLog.fromTarget = () => {
return fakeTarget.networkLog;
};

return fakeTarget.networkManager;
};

// Dependencies for effective CSS rule calculation.
require('chrome-devtools-frontend/front_end/common/TextRange.js');
require('chrome-devtools-frontend/front_end/sdk/CSSMatchedStyles.js');
Expand Down
1 change: 0 additions & 1 deletion lighthouse-core/test/lib/web-inspector-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ describe('Web Inspector lib', function() {
assert.ok(WebInspector.FilmStripModel);
assert.ok(WebInspector.TimelineProfileTree);
assert.ok(WebInspector.TimelineAggregator);
assert.ok(WebInspector.NetworkManager);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lol this test

assert.ok(WebInspector.Color);
assert.ok(WebInspector.CSSMetadata);
});
Expand Down