Bug 1600704 - Hardcode support for intent URIs so that they always get passed to onLoadRequest. r=snorp

Differential Revision: https://phabricator.services.mozilla.com/D64395

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Dylan Roeh 2020-02-26 16:36:43 +00:00
parent 32800c141f
commit 20feb8ff78
2 changed files with 26 additions and 3 deletions

View File

@ -23,6 +23,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import org.hamcrest.MatcherAssert
import org.hamcrest.Matchers.*
import org.json.JSONObject
import org.junit.Assume.assumeThat
import org.junit.Ignore
import org.junit.Test
import org.junit.runner.RunWith
@ -363,6 +364,26 @@ class NavigationDelegateTest : BaseSessionTest() {
})
}
@Test fun redirectIntentLoad() {
assumeThat(sessionRule.env.isAutomation, equalTo(true))
val redirectUri = "intent://test"
val uri = "http://example.org/tests/junit/simple_redirect.sjs?$redirectUri"
sessionRule.session.loadUri(uri)
sessionRule.waitForPageStop()
sessionRule.forCallbacksDuringWait(object : Callbacks.NavigationDelegate {
@AssertCalled(count = 2, order = [1, 2])
override fun onLoadRequest(session: GeckoSession,
request: LoadRequest):
GeckoResult<AllowOrDeny>? {
assertThat("URL should match", request.uri, equalTo(forEachCall(uri, redirectUri)))
return null
}
})
}
@Test fun bypassClassifier() {
val phishingUri = "https://www.itisatrap.org/firefox/its-a-trap.html"

View File

@ -34,9 +34,11 @@ nsresult nsOSHelperAppService::GetMIMEInfoFromOS(const nsACString& aMIMEType,
nsresult nsOSHelperAppService::OSProtocolHandlerExists(const char* aScheme,
bool* aExists) {
// We don't want to get protocol handlers from the OS in GV; the app
// should take care of that in NavigationDelegate.onLoadRequest().
return NS_ERROR_NOT_IMPLEMENTED;
// Hard-code support for intent URIs until we have a more general solution
// for letting the app decide which schemes to handle.
nsAutoCString scheme(aScheme);
*aExists = scheme.Equals(NS_LITERAL_CSTRING("intent"));
return NS_OK;
}
NS_IMETHODIMP