зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1508660 - introduce getCachedFront; r=ochameau
Depends on D12439 Differential Revision: https://phabricator.services.mozilla.com/D13110 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
0913e97c35
Коммит
26f279b0fb
|
@ -593,10 +593,17 @@ function createHighlightButton(highlighterName, id) {
|
|||
return highlighter.show({});
|
||||
},
|
||||
isChecked(toolbox) {
|
||||
if (!toolbox.inspector) {
|
||||
// if the inspector doesn't exist, then the highlighter has not yet been connected
|
||||
// to the front end.
|
||||
const inspectorFront = toolbox.target.getCachedFront("inspector");
|
||||
if (!inspectorFront) {
|
||||
// initialize the inspector front asyncronously. There is a potential for buggy
|
||||
// behavior here, but we need to change how the buttons get data (have them
|
||||
// consume data from reducers rather than writing our own version) in order to
|
||||
// fix this properly.
|
||||
return false;
|
||||
}
|
||||
const highlighter = toolbox.inspector.getKnownHighlighter(highlighterName);
|
||||
const highlighter = inspectorFront.getKnownHighlighter(highlighterName);
|
||||
return highlighter && highlighter.isShown();
|
||||
},
|
||||
};
|
||||
|
|
|
@ -398,11 +398,24 @@ Target.prototype = {
|
|||
return front;
|
||||
}
|
||||
front = getFront(this.client, typeName, this.form);
|
||||
this.fronts.set(typeName, front);
|
||||
// replace the placeholder with the instance of the front once it has loaded
|
||||
front = await front;
|
||||
this.emit(typeName, front);
|
||||
this.fronts.set(typeName, front);
|
||||
return front;
|
||||
},
|
||||
|
||||
getCachedFront(typeName) {
|
||||
// do not wait for async fronts;
|
||||
const front = this.fronts.get(typeName);
|
||||
// ensure that the front is a front, and not async front
|
||||
if (front && front.actorID) {
|
||||
return front;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
get client() {
|
||||
return this._client;
|
||||
},
|
||||
|
|
|
@ -76,6 +76,7 @@ skip-if = os == 'win' || debug # Bug 1282269, 1448084
|
|||
[browser_source_map-reload.js]
|
||||
[browser_source_map-late-script.js]
|
||||
[browser_target_from_url.js]
|
||||
[browser_target_cached-front.js]
|
||||
[browser_target_events.js]
|
||||
[browser_target_remote.js]
|
||||
[browser_target_support.js]
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
add_task(async function() {
|
||||
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
|
||||
await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
|
||||
|
||||
const target = await TargetFactory.forTab(gBrowser.selectedTab);
|
||||
await target.attach();
|
||||
|
||||
info("Cached front when getFront has not been called");
|
||||
let getCachedFront = target.getCachedFront("accessibility");
|
||||
ok(!getCachedFront, "no front exists");
|
||||
|
||||
info("Cached front when getFront has been called but has not finished");
|
||||
const asyncFront = target.getFront("accessibility");
|
||||
getCachedFront = target.getCachedFront("accessibility");
|
||||
ok(!getCachedFront, "no front exists");
|
||||
|
||||
info("Cached front when getFront has been called and has finished");
|
||||
const front = await asyncFront;
|
||||
getCachedFront = target.getCachedFront("accessibility");
|
||||
is(getCachedFront, front, "front is the same as async front");
|
||||
});
|
Загрузка…
Ссылка в новой задаче