зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1003461 - Shift + Switch to Tab no longer respected. r=mano
This commit is contained in:
Родитель
91ec3a6aac
Коммит
6119e4a521
|
@ -425,3 +425,4 @@ skip-if = e10s # Bug 516755 - SessionStore disabled for e10s
|
||||||
skip-if = e10s # Bug 940206 - nsIWebContentHandlerRegistrar::registerProtocolHandler doesn't work in e10s
|
skip-if = e10s # Bug 940206 - nsIWebContentHandlerRegistrar::registerProtocolHandler doesn't work in e10s
|
||||||
[browser_no_mcb_on_http_site.js]
|
[browser_no_mcb_on_http_site.js]
|
||||||
skip-if = e10s # Bug 516755 - SessionStore disabled for e10s
|
skip-if = e10s # Bug 516755 - SessionStore disabled for e10s
|
||||||
|
[browser_bug1003461-switchtab-override.js]
|
||||||
|
|
|
@ -0,0 +1,63 @@
|
||||||
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
add_task(function* test_switchtab_override() {
|
||||||
|
let testURL = "http://example.org/browser/browser/base/content/test/general/dummy_page.html";
|
||||||
|
|
||||||
|
info("Opening first tab");
|
||||||
|
let tab = gBrowser.addTab(testURL);
|
||||||
|
let deferred = Promise.defer();
|
||||||
|
whenTabLoaded(tab, deferred.resolve);
|
||||||
|
yield deferred.promise;
|
||||||
|
|
||||||
|
info("Opening and selecting second tab");
|
||||||
|
let secondTab = gBrowser.selectedTab = gBrowser.addTab();
|
||||||
|
registerCleanupFunction(() => {
|
||||||
|
try {
|
||||||
|
gBrowser.removeTab(tab);
|
||||||
|
gBrowser.removeTab(secondTab);
|
||||||
|
} catch(ex) { /* tabs may have already been closed in case of failure */ }
|
||||||
|
});
|
||||||
|
|
||||||
|
info("Wait for autocomplete")
|
||||||
|
deferred = Promise.defer();
|
||||||
|
let onSearchComplete = gURLBar.onSearchComplete;
|
||||||
|
registerCleanupFunction(() => {
|
||||||
|
gURLBar.onSearchComplete = onSearchComplete;
|
||||||
|
});
|
||||||
|
gURLBar.onSearchComplete = function () {
|
||||||
|
ok(gURLBar.popupOpen, "The autocomplete popup is correctly open");
|
||||||
|
onSearchComplete.apply(gURLBar);
|
||||||
|
deferred.resolve();
|
||||||
|
}
|
||||||
|
|
||||||
|
gURLBar.focus();
|
||||||
|
gURLBar.value = "dummy_pag";
|
||||||
|
EventUtils.synthesizeKey("e" , {});
|
||||||
|
yield deferred.promise;
|
||||||
|
|
||||||
|
info("Select first autocomplete popup entry");
|
||||||
|
EventUtils.synthesizeKey("VK_DOWN" , {});
|
||||||
|
ok(/moz-action:switchtab/.test(gURLBar.value), "switch to tab entry found");
|
||||||
|
|
||||||
|
info("Override switch-to-tab");
|
||||||
|
let deferred = Promise.defer();
|
||||||
|
// In case of failure this would switch tab.
|
||||||
|
let onTabSelect = event => {
|
||||||
|
deferred.reject(new Error("Should have overridden switch to tab"));
|
||||||
|
};
|
||||||
|
gBrowser.tabContainer.addEventListener("TabSelect", onTabSelect, false);
|
||||||
|
registerCleanupFunction(() => {
|
||||||
|
gBrowser.tabContainer.removeEventListener("TabSelect", onTabSelect, false);
|
||||||
|
});
|
||||||
|
// Otherwise it would load the page.
|
||||||
|
whenTabLoaded(secondTab, deferred.resolve);
|
||||||
|
|
||||||
|
EventUtils.synthesizeKey("VK_SHIFT" , { type: "keydown" });
|
||||||
|
EventUtils.synthesizeKey("VK_RETURN" , { });
|
||||||
|
EventUtils.synthesizeKey("VK_SHIFT" , { type: "keyup" });
|
||||||
|
yield deferred.promise;
|
||||||
|
|
||||||
|
yield promiseClearHistory();
|
||||||
|
});
|
|
@ -292,6 +292,39 @@ function promiseHistoryClearedState(aURIs, aShouldBeCleared) {
|
||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows waiting for an observer notification once.
|
||||||
|
*
|
||||||
|
* @param topic
|
||||||
|
* Notification topic to observe.
|
||||||
|
*
|
||||||
|
* @return {Promise}
|
||||||
|
* @resolves The array [subject, data] from the observed notification.
|
||||||
|
* @rejects Never.
|
||||||
|
*/
|
||||||
|
function promiseTopicObserved(topic)
|
||||||
|
{
|
||||||
|
let deferred = Promise.defer();
|
||||||
|
Services.obs.addObserver(function PTO_observe(subject, topic, data) {
|
||||||
|
Services.obs.removeObserver(PTO_observe, topic);
|
||||||
|
deferred.resolve([subject, data]);
|
||||||
|
}, topic, false);
|
||||||
|
return deferred.promise;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears history asynchronously.
|
||||||
|
*
|
||||||
|
* @return {Promise}
|
||||||
|
* @resolves When history has been cleared.
|
||||||
|
* @rejects Never.
|
||||||
|
*/
|
||||||
|
function promiseClearHistory() {
|
||||||
|
let promise = promiseTopicObserved(PlacesUtils.TOPIC_EXPIRATION_FINISHED);
|
||||||
|
PlacesUtils.bhistory.removeAllPages();
|
||||||
|
return promise;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Waits for the next top-level document load in the current browser. The URI
|
* Waits for the next top-level document load in the current browser. The URI
|
||||||
* of the document is compared against aExpectedURL. The load is then stopped
|
* of the document is compared against aExpectedURL. The load is then stopped
|
||||||
|
|
|
@ -143,7 +143,9 @@
|
||||||
this._value = aValue;
|
this._value = aValue;
|
||||||
var returnValue = aValue;
|
var returnValue = aValue;
|
||||||
var action = this._parseActionUrl(aValue);
|
var action = this._parseActionUrl(aValue);
|
||||||
if (action) {
|
// Don't put back the action if we are invoked while override actions
|
||||||
|
// is active.
|
||||||
|
if (action && this._numNoActionsKeys <= 0) {
|
||||||
returnValue = action.param;
|
returnValue = action.param;
|
||||||
this.setAttribute("actiontype", action.type);
|
this.setAttribute("actiontype", action.type);
|
||||||
} else {
|
} else {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче