Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(194)

Unified Diff: third_party/WebKit/Source/devtools/front_end/audits2/Audits2Panel.js

Issue 2895913003: DevTools: Audits2 use location.href when available (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/devtools/front_end/audits2/Audits2Panel.js
diff --git a/third_party/WebKit/Source/devtools/front_end/audits2/Audits2Panel.js b/third_party/WebKit/Source/devtools/front_end/audits2/Audits2Panel.js
index ff23436b180b2d3c5ac373030dc4ccc5c2608cc1..324b87d0e26da003bc59dbcce130c156892d3146 100644
--- a/third_party/WebKit/Source/devtools/front_end/audits2/Audits2Panel.js
+++ b/third_party/WebKit/Source/devtools/front_end/audits2/Audits2Panel.js
@@ -142,6 +142,25 @@ Audits2.Audits2Panel = class extends UI.PanelWithSidebar {
return statusView;
}
+ _updateInspectedURL() {
dgozman 2017/05/22 18:50:34 JSDoc please.
phulce 2017/05/22 19:10:16 Done.
+ var mainTarget = SDK.targetManager.mainTarget();
+ var runtimeModel = /** @type {!SDK.RuntimeModel} */ (mainTarget.model(SDK.RuntimeModel));
dgozman 2017/05/22 18:50:34 No need to cast, instead do the following in next
phulce 2017/05/22 19:10:16 Done.
+ var executionContext = runtimeModel.defaultExecutionContext();
+ if (!executionContext) {
+ this.inspectedURL = mainTarget.inspectedURL();
caseq 2017/05/22 18:53:06 did you mean _inspectedURL?
phulce 2017/05/22 19:10:16 whoops, yes :)
+ return;
+ }
+
+ return new Promise((resolve, reject) => {
dgozman 2017/05/22 18:50:34 We don't usually reject promises.
phulce 2017/05/22 19:10:16 Gotcha, so we have a general preference to silentl
+ executionContext.evaluate('window.location.href', 'audits', false, false, true, false, false, (object, err) => {
+ if (err || !object)
+ return reject(err || new Error('Failed to retrieve page URL'));
dgozman 2017/05/22 18:50:34 Just resolve with mainTarget.inspectedURL()
phulce 2017/05/22 19:10:16 Done.
+ this._inspectedURL = object.value;
+ resolve();
+ });
+ });
+ }
+
_start() {
var emulationModel = self.singleton(Emulation.DeviceModeModel);
this._emulationEnabledBefore = emulationModel.enabledSetting().get();
@@ -155,7 +174,6 @@ Audits2.Audits2Panel = class extends UI.PanelWithSidebar {
emulationModel.emulate(Emulation.DeviceModeModel.Type.Device, device, device.modes[0], 1);
}
this._dialog.setCloseOnEscape(false);
- this._inspectedURL = SDK.targetManager.mainTarget().inspectedURL();
var categoryIDs = [];
for (var preset of Audits2.Audits2Panel.Presets) {
@@ -164,6 +182,7 @@ Audits2.Audits2Panel = class extends UI.PanelWithSidebar {
}
return Promise.resolve()
+ .then(_ => this._updateInspectedURL())
.then(_ => this._protocolService.attach())
.then(_ => {
this._auditRunning = true;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698