Bug 1501801 - Add query string to URI that test SafeBrowsing. r=francois a=test-only
authordlee <dlee@mozilla.com>
Fri, 09 Nov 2018 05:02:00 +0200
changeset 498416 a952926f449c
parent 498415 5013a75792e7
child 498417 9089a3c9c65b
push id10148
push userebalazs@mozilla.com
push dateFri, 09 Nov 2018 13:29:09 +0000
treeherdermozilla-beta@a952926f449c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfrancois, test-only
bugs1501801
milestone64.0
Bug 1501801 - Add query string to URI that test SafeBrowsing. r=francois a=test-only Summary: The SafeBrowsing related testcases in NavigationDelegateTest.kt first tests loading bad URI and then tests loading the URI again with |blockMalware| disabled. When the testcase loads a bad URI with |blockMalware| disabled, the load succeed and the HTTP response of the URI is stored in HTTP cache. The next time we run the same test, the load is read from the cache without going through url-classifier hence the load is not blocked. Add query string to the URI to avoid bypassing url-classifier check. Reviewers: francois Reviewed By: francois Bug #: 1501801 Differential Revision: https://phabricator.services.mozilla.com/D10886
mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/NavigationDelegateTest.kt
--- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/NavigationDelegateTest.kt
+++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/NavigationDelegateTest.kt
@@ -239,23 +239,24 @@ class NavigationDelegateTest : BaseSessi
         })
     }
 
     @Test fun safebrowsingPhishing() {
         val phishingUri = "https://www.itisatrap.org/firefox/its-a-trap.html"
 
         sessionRule.runtime.settings.blockPhishing = true
 
-        testLoadExpectError(phishingUri,
+        // Add query string to avoid bypassing classifier check because of cache.
+        testLoadExpectError(phishingUri + "?block=true",
                         GeckoSession.NavigationDelegate.ERROR_CATEGORY_SAFEBROWSING,
                         GeckoSession.NavigationDelegate.ERROR_SAFEBROWSING_PHISHING_URI)
 
         sessionRule.runtime.settings.blockPhishing = false
 
-        sessionRule.session.loadUri(phishingUri)
+        sessionRule.session.loadUri(phishingUri + "?block=false")
         sessionRule.session.waitForPageStop()
 
         sessionRule.forCallbacksDuringWait(
                 object : Callbacks.NavigationDelegate {
             @AssertCalled(false)
             override fun onLoadError(session: GeckoSession, uri: String?,
                                      category: Int, error: Int): GeckoResult<String>? {
                 return null
@@ -263,23 +264,23 @@ class NavigationDelegateTest : BaseSessi
         })
     }
 
     @Test fun safebrowsingMalware() {
         val malwareUri = "https://www.itisatrap.org/firefox/its-an-attack.html"
 
         sessionRule.runtime.settings.blockMalware = true
 
-        testLoadExpectError(malwareUri,
+        testLoadExpectError(malwareUri + "?block=true",
                         GeckoSession.NavigationDelegate.ERROR_CATEGORY_SAFEBROWSING,
                         GeckoSession.NavigationDelegate.ERROR_SAFEBROWSING_MALWARE_URI)
 
         sessionRule.runtime.settings.blockMalware = false
 
-        sessionRule.session.loadUri(malwareUri)
+        sessionRule.session.loadUri(malwareUri + "?block=false")
         sessionRule.session.waitForPageStop()
 
         sessionRule.forCallbacksDuringWait(
                 object : Callbacks.NavigationDelegate {
             @AssertCalled(false)
             override fun onLoadError(session: GeckoSession, uri: String?,
                                      category: Int, error: Int): GeckoResult<String>? {
                 return null
@@ -287,23 +288,23 @@ class NavigationDelegateTest : BaseSessi
         })
     }
 
     @Test fun safebrowsingUnwanted() {
         val unwantedUri = "https://www.itisatrap.org/firefox/unwanted.html"
 
         sessionRule.runtime.settings.blockMalware = true
 
-        testLoadExpectError(unwantedUri,
+        testLoadExpectError(unwantedUri + "?block=true",
                         GeckoSession.NavigationDelegate.ERROR_CATEGORY_SAFEBROWSING,
                         GeckoSession.NavigationDelegate.ERROR_SAFEBROWSING_UNWANTED_URI)
 
         sessionRule.runtime.settings.blockMalware = false
 
-        sessionRule.session.loadUri(unwantedUri)
+        sessionRule.session.loadUri(unwantedUri + "?block=false")
         sessionRule.session.waitForPageStop()
 
         sessionRule.forCallbacksDuringWait(
                 object : Callbacks.NavigationDelegate {
             @AssertCalled(false)
             override fun onLoadError(session: GeckoSession, uri: String?,
                                      category: Int, error: Int): GeckoResult<String>? {
                 return null
@@ -311,23 +312,23 @@ class NavigationDelegateTest : BaseSessi
         })
     }
 
     @Test fun safebrowsingHarmful() {
         val harmfulUri = "https://www.itisatrap.org/firefox/harmful.html"
 
         sessionRule.runtime.settings.blockMalware = true
 
-        testLoadExpectError(harmfulUri,
+        testLoadExpectError(harmfulUri + "?block=true",
                         GeckoSession.NavigationDelegate.ERROR_CATEGORY_SAFEBROWSING,
                         GeckoSession.NavigationDelegate.ERROR_SAFEBROWSING_HARMFUL_URI)
 
         sessionRule.runtime.settings.blockMalware = false
 
-        sessionRule.session.loadUri(harmfulUri)
+        sessionRule.session.loadUri(harmfulUri + "?block=false")
         sessionRule.session.waitForPageStop()
 
         sessionRule.forCallbacksDuringWait(
                 object : Callbacks.NavigationDelegate {
             @AssertCalled(false)
             override fun onLoadError(session: GeckoSession, uri: String?,
                                      category: Int, error: Int): GeckoResult<String>? {
                 return null