mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-22 17:55:50 +00:00
Bug 1240804 - Ignore actions dispatched after RDM close. r=me
MozReview-Commit-ID: Kby5Zy4jeZ2
This commit is contained in:
parent
053ffc34df
commit
3025dab95c
@ -47,6 +47,7 @@ let bootstrap = {
|
||||
});
|
||||
let provider = createElement(Provider, { store }, app);
|
||||
ReactDOM.render(provider, document.querySelector("#root"));
|
||||
this.initDevices();
|
||||
window.postMessage({ type: "init" }, "*");
|
||||
},
|
||||
|
||||
@ -62,9 +63,28 @@ let bootstrap = {
|
||||
* to dispatch. They can do so here.
|
||||
*/
|
||||
dispatch(action) {
|
||||
if (!this.store) {
|
||||
// If actions are dispatched after store is destroyed, ignore them. This
|
||||
// can happen in tests that close the tool quickly while async tasks like
|
||||
// initDevices() below are still pending.
|
||||
return;
|
||||
}
|
||||
this.store.dispatch(action);
|
||||
},
|
||||
|
||||
initDevices() {
|
||||
GetDevices().then(devices => {
|
||||
for (let type of devices.TYPES) {
|
||||
this.dispatch(addDeviceType(type));
|
||||
for (let device of devices[type]) {
|
||||
if (device.os != "fxos") {
|
||||
this.dispatch(addDevice(device, type));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
window.addEventListener("load", function onLoad() {
|
||||
@ -92,18 +112,6 @@ Object.defineProperty(window, "store", {
|
||||
window.addInitialViewport = contentURI => {
|
||||
try {
|
||||
bootstrap.dispatch(changeLocation(contentURI));
|
||||
|
||||
GetDevices().then(devices => {
|
||||
for (let type of devices.TYPES) {
|
||||
bootstrap.dispatch(addDeviceType(type));
|
||||
for (let device of devices[type]) {
|
||||
if (device.os != "fxos") {
|
||||
bootstrap.dispatch(addDevice(device, type));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
bootstrap.dispatch(addViewport());
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
|
@ -16,6 +16,8 @@ Services.scriptloader.loadSubScript(
|
||||
|
||||
const TEST_URI_ROOT = "http://example.com/browser/devtools/client/responsive.html/test/browser/";
|
||||
|
||||
SimpleTest.requestCompleteLog();
|
||||
|
||||
DevToolsUtils.testing = true;
|
||||
Services.prefs.setCharPref("devtools.devices.url",
|
||||
TEST_URI_ROOT + "devices.json");
|
||||
|
Loading…
Reference in New Issue
Block a user