зеркало из https://github.com/mozilla/gecko-dev.git
Bug 635844 part 3: Update extension manager and tests to new pushState behavior. r=mossop. Includes parts by mossop which are r=me. a=jst
This commit is contained in:
Родитель
ce5698e6e2
Коммит
f2653d1f69
|
@ -111,6 +111,9 @@ function initialize() {
|
||||||
gEventManager.initialize();
|
gEventManager.initialize();
|
||||||
Services.obs.addObserver(sendEMPong, "EM-ping", false);
|
Services.obs.addObserver(sendEMPong, "EM-ping", false);
|
||||||
Services.obs.notifyObservers(window, "EM-loaded", "");
|
Services.obs.notifyObservers(window, "EM-loaded", "");
|
||||||
|
// Send this after the above notifications to give observers of them a chance
|
||||||
|
// to initialize us to a different view.
|
||||||
|
gViewController.updateState(window.history.state);
|
||||||
}
|
}
|
||||||
|
|
||||||
function notifyInitialized() {
|
function notifyInitialized() {
|
||||||
|
@ -219,7 +222,7 @@ var FakeHistory = {
|
||||||
throw new Error("Cannot go back from this point");
|
throw new Error("Cannot go back from this point");
|
||||||
|
|
||||||
this.pos--;
|
this.pos--;
|
||||||
gViewController.statePopped({ state: this.states[this.pos] });
|
gViewController.updateState(this.states[this.pos]);
|
||||||
gViewController.updateCommand("cmd_back");
|
gViewController.updateCommand("cmd_back");
|
||||||
gViewController.updateCommand("cmd_forward");
|
gViewController.updateCommand("cmd_forward");
|
||||||
},
|
},
|
||||||
|
@ -229,7 +232,7 @@ var FakeHistory = {
|
||||||
throw new Error("Cannot go forward from this point");
|
throw new Error("Cannot go forward from this point");
|
||||||
|
|
||||||
this.pos++;
|
this.pos++;
|
||||||
gViewController.statePopped({ state: this.states[this.pos] });
|
gViewController.updateState(this.states[this.pos]);
|
||||||
gViewController.updateCommand("cmd_back");
|
gViewController.updateCommand("cmd_back");
|
||||||
gViewController.updateCommand("cmd_forward");
|
gViewController.updateCommand("cmd_forward");
|
||||||
},
|
},
|
||||||
|
@ -251,7 +254,7 @@ var FakeHistory = {
|
||||||
this.states.splice(this.pos);
|
this.states.splice(this.pos);
|
||||||
this.pos--;
|
this.pos--;
|
||||||
|
|
||||||
gViewController.statePopped({ state: this.states[this.pos] });
|
gViewController.updateState(this.states[this.pos]);
|
||||||
gViewController.updateCommand("cmd_back");
|
gViewController.updateCommand("cmd_back");
|
||||||
gViewController.updateCommand("cmd_forward");
|
gViewController.updateCommand("cmd_forward");
|
||||||
}
|
}
|
||||||
|
@ -486,7 +489,9 @@ var gViewController = {
|
||||||
window.controllers.appendController(this);
|
window.controllers.appendController(this);
|
||||||
|
|
||||||
window.addEventListener("popstate",
|
window.addEventListener("popstate",
|
||||||
gViewController.statePopped.bind(gViewController),
|
function (e) {
|
||||||
|
gViewController.updateState(e.state);
|
||||||
|
},
|
||||||
false);
|
false);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -509,10 +514,10 @@ var gViewController = {
|
||||||
window.controllers.removeController(this);
|
window.controllers.removeController(this);
|
||||||
},
|
},
|
||||||
|
|
||||||
statePopped: function(e) {
|
updateState: function(state) {
|
||||||
// If this is a navigation to a previous state then load that state
|
// If this is a navigation to a previous state then load that state
|
||||||
if (e.state) {
|
if (state) {
|
||||||
this.loadViewInternal(e.state.view, e.state.previousView, e.state);
|
this.loadViewInternal(state.view, state.previousView, state);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1797,10 +1802,8 @@ var gDiscoverView = {
|
||||||
if (!(aStateFlags & (Ci.nsIWebProgressListener.STATE_STOP)))
|
if (!(aStateFlags & (Ci.nsIWebProgressListener.STATE_STOP)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var location = this._browser.currentURI;
|
|
||||||
|
|
||||||
// Consider the successful load of about:blank as still loading
|
// Consider the successful load of about:blank as still loading
|
||||||
if (Components.isSuccessCode(aStatus) && location && location.spec == "about:blank")
|
if (aRequest instanceof Ci.nsIChannel && aRequest.URI.spec == "about:blank")
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// If there was an error loading the page or the new hostname is not the
|
// If there was an error loading the page or the new hostname is not the
|
||||||
|
|
|
@ -235,6 +235,7 @@ function open_manager(aView, aCallback, aLoadCallback, aLongerTimeout) {
|
||||||
ok(aManagerWindow != null, "Should have an add-ons manager window");
|
ok(aManagerWindow != null, "Should have an add-ons manager window");
|
||||||
is(aManagerWindow.location, MANAGER_URI, "Should be displaying the correct UI");
|
is(aManagerWindow.location, MANAGER_URI, "Should be displaying the correct UI");
|
||||||
|
|
||||||
|
waitForFocus(function() {
|
||||||
wait_for_manager_load(aManagerWindow, function() {
|
wait_for_manager_load(aManagerWindow, function() {
|
||||||
wait_for_view_load(aManagerWindow, function() {
|
wait_for_view_load(aManagerWindow, function() {
|
||||||
// Some functions like synthesizeMouse don't like to be called during
|
// Some functions like synthesizeMouse don't like to be called during
|
||||||
|
@ -244,24 +245,29 @@ function open_manager(aView, aCallback, aLoadCallback, aLongerTimeout) {
|
||||||
});
|
});
|
||||||
}, null, aLongerTimeout);
|
}, null, aLongerTimeout);
|
||||||
});
|
});
|
||||||
|
}, aManagerWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gUseInContentUI) {
|
if (gUseInContentUI) {
|
||||||
gBrowser.selectedTab = gBrowser.addTab();
|
gBrowser.selectedTab = gBrowser.addTab();
|
||||||
switchToTabHavingURI(MANAGER_URI, true);
|
switchToTabHavingURI(MANAGER_URI, true);
|
||||||
gBrowser.selectedBrowser.addEventListener("pageshow", function (event) {
|
|
||||||
if (event.target.location.href != MANAGER_URI)
|
// This must be a new load, else the ping/pong would have
|
||||||
|
// found the window above.
|
||||||
|
Services.obs.addObserver(function (aSubject, aTopic, aData) {
|
||||||
|
Services.obs.removeObserver(arguments.callee, aTopic);
|
||||||
|
if (aSubject.location.href != MANAGER_URI)
|
||||||
return;
|
return;
|
||||||
gBrowser.selectedBrowser.removeEventListener("pageshow", arguments.callee, true);
|
setup_manager(aSubject);
|
||||||
setup_manager(gBrowser.contentWindow.wrappedJSObject);
|
}, "EM-loaded", false);
|
||||||
}, true);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
openDialog(MANAGER_URI).addEventListener("pageshow", function() {
|
openDialog(MANAGER_URI);
|
||||||
this.removeEventListener("pageshow", arguments.callee, true);
|
Services.obs.addObserver(function (aSubject, aTopic, aData) {
|
||||||
setup_manager(this);
|
Services.obs.removeObserver(arguments.callee, aTopic);
|
||||||
}, true);
|
setup_manager(aSubject);
|
||||||
|
}, "EM-loaded", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
function close_manager(aManagerWindow, aCallback, aLongerTimeout) {
|
function close_manager(aManagerWindow, aCallback, aLongerTimeout) {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче