зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset bb055da29523 (bug 1717314) for causing bc failures in browser_protocol_ask_dialog_external. CLOSED TREE
This commit is contained in:
Родитель
05adfdc0b7
Коммит
9a31129771
|
@ -3835,13 +3835,6 @@ already_AddRefed<nsILoadInfo> HttpBaseChannel::CloneLoadInfoForRedirect(
|
|||
// Reset our sandboxed null principal ID when cloning loadInfo for an
|
||||
// externally visible redirect.
|
||||
if (!isInternalRedirect) {
|
||||
// If we've redirected from http to something that isn't, clear
|
||||
// the "external" flag, as loads that now go to other apps should be
|
||||
// allowed to go ahead and not trip infinite-loop protection
|
||||
// (see bug 1717314 for context).
|
||||
if (!aNewURI->SchemeIs("http") && !aNewURI->SchemeIs("https")) {
|
||||
newLoadInfo->SetLoadTriggeredFromExternal(false);
|
||||
}
|
||||
newLoadInfo->ResetSandboxedNullPrincipalID();
|
||||
}
|
||||
|
||||
|
|
|
@ -568,8 +568,6 @@ HandlerService.prototype = {
|
|||
for (let extension of storedHandlerInfo.extensions) {
|
||||
handlerInfo.appendExtension(extension);
|
||||
}
|
||||
} else if (this._mockedHandler) {
|
||||
this._insertMockedHandler(handlerInfo);
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -734,48 +732,6 @@ HandlerService.prototype = {
|
|||
}
|
||||
return "";
|
||||
},
|
||||
|
||||
_mockedHandler: null,
|
||||
_mockedProtocol: null,
|
||||
|
||||
_insertMockedHandler(handlerInfo) {
|
||||
if (handlerInfo.type == this._mockedProtocol) {
|
||||
handlerInfo.preferredApplicationHandler = this._mockedHandler;
|
||||
handlerInfo.possibleApplicationHandlers.insertElementAt(
|
||||
this._mockedHandler,
|
||||
0
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
// test-only: mock the handler instance for a particular protocol/scheme
|
||||
mockProtocolHandler(protocol) {
|
||||
if (!protocol) {
|
||||
this._mockedProtocol = null;
|
||||
this._mockedHandler = null;
|
||||
return;
|
||||
}
|
||||
this._mockedProtocol = protocol;
|
||||
this._mockedHandler = {
|
||||
QueryInterface: ChromeUtils.generateQI([Ci.nsILocalHandlerApp]),
|
||||
launchWithURI(uri, context) {
|
||||
Services.obs.notifyObservers(uri, "mocked-protocol-handler");
|
||||
},
|
||||
name: "Mocked handler",
|
||||
detailedDescription: "Mocked handler for tests",
|
||||
equals(x) {
|
||||
return x == this;
|
||||
},
|
||||
executable: Services.dirsvc.get("XCurProcD", Ci.nsIFile),
|
||||
parameterCount: 0,
|
||||
clearParameters() {},
|
||||
appendParameter() {},
|
||||
getParameter() {},
|
||||
parameterExists() {
|
||||
return false;
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
this.NSGetFactory = ComponentUtils.generateNSGetFactory([HandlerService]);
|
||||
|
|
|
@ -56,8 +56,6 @@ support-files =
|
|||
support-files =
|
||||
file_external_protocol_iframe.html
|
||||
[browser_protocol_ask_dialog_external.js]
|
||||
support-files =
|
||||
redirect_helper.sjs
|
||||
[browser_protocol_ask_dialog_permission.js]
|
||||
[browser_protocolhandler_loop.js]
|
||||
[browser_remember_download_option.js]
|
||||
|
|
|
@ -7,17 +7,12 @@ let gHandlerService = Cc["@mozilla.org/uriloader/handler-service;1"].getService(
|
|||
Ci.nsIHandlerService
|
||||
);
|
||||
|
||||
const TEST_PATH = getRootDirectory(gTestPath).replace(
|
||||
"chrome://mochitests/content",
|
||||
"http://example.com"
|
||||
);
|
||||
|
||||
/**
|
||||
* Creates dummy protocol handler
|
||||
*/
|
||||
function initTestHandlers() {
|
||||
let handlerInfoThatAsks = HandlerServiceTestUtils.getBlankHandlerInfo(
|
||||
"local-app-test"
|
||||
"should-ask"
|
||||
);
|
||||
|
||||
let appHandler = Cc[
|
||||
|
@ -113,7 +108,7 @@ add_task(async function test_external_asks_anyway() {
|
|||
gBrowser,
|
||||
true
|
||||
);
|
||||
let fakeCmdLine = makeCmdLineHelper("local-app-test:dummy");
|
||||
let fakeCmdLine = makeCmdLineHelper("should-ask:dummy");
|
||||
cmdLineHandler.handle(fakeCmdLine);
|
||||
let dialog = await chooserDialogOpenPromise;
|
||||
ok(dialog, "Should have prompted.");
|
||||
|
@ -174,52 +169,3 @@ add_task(async function test_web_app_doesnt_ask() {
|
|||
dialogOpenListener
|
||||
);
|
||||
});
|
||||
|
||||
add_task(async function external_https_redirect_doesnt_ask() {
|
||||
// Listen for a dialog open and fail the test if it does:
|
||||
let dialogOpenListener = () => ok(false, "Shouldn't have opened a dialog!");
|
||||
document.documentElement.addEventListener("dialogopen", dialogOpenListener);
|
||||
registerCleanupFunction(() =>
|
||||
document.documentElement.removeEventListener(
|
||||
"dialogopen",
|
||||
dialogOpenListener
|
||||
)
|
||||
);
|
||||
|
||||
let initialTab = gBrowser.selectedTab;
|
||||
|
||||
gHandlerService.wrappedJSObject.mockProtocolHandler("local-app-test");
|
||||
registerCleanupFunction(() =>
|
||||
gHandlerService.wrappedJSObject.mockProtocolHandler()
|
||||
);
|
||||
|
||||
// Set up a promise for an app to have launched with the right URI:
|
||||
let loadPromise = TestUtils.topicObserved("mocked-protocol-handler");
|
||||
|
||||
// Load the URL:
|
||||
const kURL = "local-app-test:redirect";
|
||||
let cmdLineHandler = Cc["@mozilla.org/browser/final-clh;1"].getService(
|
||||
Ci.nsICommandLineHandler
|
||||
);
|
||||
let fakeCmdLine = makeCmdLineHelper(
|
||||
TEST_PATH + "redirect_helper.sjs?uri=" + encodeURIComponent(kURL)
|
||||
);
|
||||
cmdLineHandler.handle(fakeCmdLine);
|
||||
|
||||
// Check that the mock app was launched. If the dialog showed instead,
|
||||
// the test will fail.
|
||||
let [uri] = await loadPromise;
|
||||
is(uri.spec, "local-app-test:redirect", "Should have seen correct URI.");
|
||||
// We might have opened a blank tab, see bug 1718104 and friends.
|
||||
if (gBrowser.selectedTab != initialTab) {
|
||||
BrowserTestUtils.removeTab(gBrowser.selectedTab);
|
||||
}
|
||||
|
||||
// We do this both here and in cleanup so it's easy to add tasks to this test,
|
||||
// and so we clean up correctly if the test aborts before we get here.
|
||||
document.documentElement.removeEventListener(
|
||||
"dialogopen",
|
||||
dialogOpenListener
|
||||
);
|
||||
gHandlerService.wrappedJSObject.mockProtocolHandler();
|
||||
});
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
Cu.importGlobalProperties(["URLSearchParams"]);
|
||||
|
||||
function handleRequest(request, response) {
|
||||
response.setStatusLine(request.httpVersion, 302, "Moved Temporarily");
|
||||
response.setHeader("Location", new URLSearchParams(request.queryString).get("uri"));
|
||||
}
|
||||
|
Загрузка…
Ссылка в новой задаче