Backed out 7 changesets (bug 1522412) for xpcshell failures at test_shouldclassify.js on a CLOSED TREE.
authorGurzau Raul <rgurzau@mozilla.com>
Thu, 21 Mar 2019 11:02:09 +0200
changeset 465384 747a5da93708d6ad12832272d794b21d825a4bb9
parent 465383 8aef30b8a2be10a22438549491fd05ee64b03fcf
child 465385 94b858d366031724359dee96d3594349defe7806
push id35738
push userccoroiu@mozilla.com
push dateThu, 21 Mar 2019 21:59:09 +0000
treeherdermozilla-central@7eb8e627961c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1522412
milestone68.0a1
backs out7c998456e1fd5aa0271b8508a25a5becec2768e0
ebb581ddf1d1fb49de6a661efa66fc5fc55641e0
850e1c68d9784a2f0e4f7226310fe6c1790a5754
fe288a48cecb6e867fb85dec61cd51017b2ee8db
5399bca472b1a519f595480e786aa970f51cbb66
91e5b339fe11c8211bced586f5eb31be46a47693
b80098d0a5c4197287582b6db0bd71aaa6bbd05c
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out 7 changesets (bug 1522412) for xpcshell failures at test_shouldclassify.js on a CLOSED TREE. Backed out changeset 7c998456e1fd (bug 1522412) Backed out changeset ebb581ddf1d1 (bug 1522412) Backed out changeset 850e1c68d978 (bug 1522412) Backed out changeset fe288a48cecb (bug 1522412) Backed out changeset 5399bca472b1 (bug 1522412) Backed out changeset 91e5b339fe11 (bug 1522412) Backed out changeset b80098d0a5c4 (bug 1522412)
accessible/base/Logging.cpp
docshell/base/nsDocShell.cpp
docshell/base/nsPingListener.cpp
dom/base/Navigator.cpp
dom/base/nsObjectLoadingContent.cpp
dom/fetch/FetchDriver.cpp
dom/html/HTMLMediaElement.cpp
dom/html/HTMLTrackElement.cpp
dom/jsurl/nsJSProtocolHandler.cpp
dom/media/ChannelMediaResource.cpp
dom/plugins/base/nsPluginHost.cpp
dom/script/ScriptLoader.cpp
dom/security/nsCSPContext.cpp
dom/workers/ScriptLoader.cpp
dom/xhr/XMLHttpRequestMainThread.cpp
image/imgLoader.cpp
layout/style/Loader.cpp
netwerk/base/nsBaseChannel.cpp
netwerk/base/nsIChannel.idl
netwerk/base/nsNetUtil.cpp
netwerk/base/nsNetUtil.h
netwerk/protocol/http/HttpBaseChannel.h
netwerk/protocol/http/nsHttpChannel.cpp
netwerk/test/unit/test_trackingProtection_annotateChannels.js
toolkit/components/telemetry/app/TelemetrySend.jsm
toolkit/components/telemetry/pings/CoveragePing.jsm
toolkit/components/url-classifier/UrlClassifierHashCompleter.jsm
toolkit/components/url-classifier/nsUrlClassifierStreamUpdater.cpp
toolkit/components/url-classifier/tests/mochitest/bug_1281083.html
toolkit/components/url-classifier/tests/mochitest/classifiedAnnotatedFrame.html
toolkit/components/url-classifier/tests/mochitest/mochitest.ini
toolkit/components/url-classifier/tests/mochitest/test_classified_annotations.html
toolkit/components/url-classifier/tests/mochitest/test_classifier_changetablepref.html
toolkit/components/url-classifier/tests/mochitest/test_classify_by_default.html
toolkit/components/url-classifier/tests/mochitest/test_trackingprotection_bug1157081.html
toolkit/components/url-classifier/tests/mochitest/trackerFrame.html
toolkit/components/url-classifier/tests/mochitest/trackerFrame.sjs
toolkit/components/url-classifier/tests/unit/test_shouldclassify.js
toolkit/components/url-classifier/tests/unit/xpcshell.ini
--- a/accessible/base/Logging.cpp
+++ b/accessible/base/Logging.cpp
@@ -306,19 +306,17 @@ static void LogRequest(nsIRequest* aRequ
     if (loadFlags & nsIChannel::LOAD_RETARGETED_DOCUMENT_URI)
       printf("retargeted document uri; ");
     if (loadFlags & nsIChannel::LOAD_REPLACE) printf("replace; ");
     if (loadFlags & nsIChannel::LOAD_INITIAL_DOCUMENT_URI)
       printf("initial document uri; ");
     if (loadFlags & nsIChannel::LOAD_TARGETED) printf("targeted; ");
     if (loadFlags & nsIChannel::LOAD_CALL_CONTENT_SNIFFERS)
       printf("call content sniffers; ");
-    if (loadFlags & nsIChannel::LOAD_BYPASS_URL_CLASSIFIER) {
-      printf("bypass classify uri; ");
-    }
+    if (loadFlags & nsIChannel::LOAD_CLASSIFY_URI) printf("classify uri; ");
   } else {
     printf("    no request");
   }
 }
 
 static void LogDocAccState(DocAccessible* aDocument) {
   printf("document acc state: ");
   if (aDocument->HasLoadState(DocAccessible::eCompletelyLoaded))
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -10358,18 +10358,18 @@ nsresult nsDocShell::DoChannelLoad(nsICh
           break;
         case 2:
           loadFlags |= nsIRequest::VALIDATE_NEVER;
           break;
       }
       break;
   }
 
-  if (aBypassClassifier) {
-    loadFlags |= nsIChannel::LOAD_BYPASS_URL_CLASSIFIER;
+  if (!aBypassClassifier) {
+    loadFlags |= nsIChannel::LOAD_CLASSIFY_URI;
   }
 
   // If the user pressed shift-reload, then do not allow ServiceWorker
   // interception to occur. See step 12.1 of the SW HandleFetch algorithm.
   if (IsForceReloading()) {
     loadFlags |= nsIChannel::LOAD_BYPASS_SERVICE_WORKER;
   }
 
--- a/docshell/base/nsPingListener.cpp
+++ b/docshell/base/nsPingListener.cpp
@@ -106,17 +106,18 @@ static void SendPing(void* aClosure, nsI
                 aIOService);
 
   if (!chan) {
     return;
   }
 
   // Don't bother caching the result of this URI load, but do not exempt
   // it from Safe Browsing.
-  chan->SetLoadFlags(nsIRequest::INHIBIT_CACHING);
+  chan->SetLoadFlags(nsIRequest::INHIBIT_CACHING |
+                     nsIChannel::LOAD_CLASSIFY_URI);
 
   nsCOMPtr<nsIHttpChannel> httpChan = do_QueryInterface(chan);
   if (!httpChan) {
     return;
   }
 
   // This is needed in order for 3rd-party cookie blocking to work.
   nsCOMPtr<nsIHttpChannelInternal> httpInternal = do_QueryInterface(httpChan);
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -1123,26 +1123,33 @@ bool Navigator::SendBeaconInternal(const
   if (!(NS_SUCCEEDED(uri->SchemeIs("http", &isValidScheme)) && isValidScheme) &&
       !(NS_SUCCEEDED(uri->SchemeIs("https", &isValidScheme)) &&
         isValidScheme)) {
     aRv.ThrowTypeError<MSG_INVALID_URL_SCHEME>(NS_LITERAL_STRING("Beacon"),
                                                aUrl);
     return false;
   }
 
+  nsLoadFlags loadFlags =
+      nsIRequest::LOAD_NORMAL | nsIChannel::LOAD_CLASSIFY_URI;
+
   // No need to use CORS for sendBeacon unless it's a BLOB
   nsSecurityFlags securityFlags =
       aType == eBeaconTypeBlob
           ? nsILoadInfo::SEC_REQUIRE_CORS_DATA_INHERITS
           : nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_INHERITS;
   securityFlags |= nsILoadInfo::SEC_COOKIES_INCLUDE;
 
   nsCOMPtr<nsIChannel> channel;
   rv = NS_NewChannel(getter_AddRefs(channel), uri, doc, securityFlags,
-                     nsIContentPolicy::TYPE_BEACON);
+                     nsIContentPolicy::TYPE_BEACON,
+                     nullptr,  // aPerformanceStorage
+                     nullptr,  // aLoadGroup
+                     nullptr,  // aCallbacks
+                     loadFlags);
 
   if (NS_FAILED(rv)) {
     aRv.Throw(rv);
     return false;
   }
 
   nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(channel);
   if (!httpChannel) {
--- a/dom/base/nsObjectLoadingContent.cpp
+++ b/dom/base/nsObjectLoadingContent.cpp
@@ -2305,24 +2305,24 @@ nsresult nsObjectLoadingContent::OpenCha
     securityFlags |= nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL;
   }
   if (isSandBoxed) {
     securityFlags |= nsILoadInfo::SEC_SANDBOXED;
   }
 
   nsContentPolicyType contentPolicyType = GetContentPolicyType();
 
-  rv = NS_NewChannel(getter_AddRefs(chan), mURI, thisContent, securityFlags,
-                     contentPolicyType,
-                     nullptr,  // aPerformanceStorage
-                     group,    // aLoadGroup
-                     shim,     // aCallbacks
-                     nsIChannel::LOAD_CALL_CONTENT_SNIFFERS |
-                         nsIChannel::LOAD_BYPASS_SERVICE_WORKER |
-                         nsIRequest::LOAD_HTML_OBJECT_DATA);
+  rv = NS_NewChannel(
+      getter_AddRefs(chan), mURI, thisContent, securityFlags, contentPolicyType,
+      nullptr,  // aPerformanceStorage
+      group,    // aLoadGroup
+      shim,     // aCallbacks
+      nsIChannel::LOAD_CALL_CONTENT_SNIFFERS | nsIChannel::LOAD_CLASSIFY_URI |
+          nsIChannel::LOAD_BYPASS_SERVICE_WORKER |
+          nsIRequest::LOAD_HTML_OBJECT_DATA);
   NS_ENSURE_SUCCESS(rv, rv);
   if (inherit) {
     nsCOMPtr<nsILoadInfo> loadinfo = chan->LoadInfo();
     loadinfo->SetPrincipalToInherit(thisContent->NodePrincipal());
   }
 
   // Referrer
   nsCOMPtr<nsIHttpChannel> httpChan(do_QueryInterface(chan));
--- a/dom/fetch/FetchDriver.cpp
+++ b/dom/fetch/FetchDriver.cpp
@@ -520,17 +520,18 @@ nsresult FetchDriver::HttpFetch(
     return NS_ERROR_UNEXPECTED;
   }
 
   // From here on we create a channel and set its properties with the
   // information from the InternalRequest. This is an implementation detail.
   MOZ_ASSERT(mLoadGroup);
   nsCOMPtr<nsIChannel> chan;
 
-  nsLoadFlags loadFlags = nsIRequest::LOAD_BACKGROUND | bypassFlag;
+  nsLoadFlags loadFlags =
+      nsIRequest::LOAD_BACKGROUND | bypassFlag | nsIChannel::LOAD_CLASSIFY_URI;
   if (mDocument) {
     MOZ_ASSERT(mDocument->NodePrincipal() == mPrincipal);
     MOZ_ASSERT(mDocument->CookieSettings() == mCookieSettings);
     rv = NS_NewChannel(getter_AddRefs(chan), uri, mDocument, secFlags,
                        mRequest->ContentPolicyType(),
                        nullptr,             /* aPerformanceStorage */
                        mLoadGroup, nullptr, /* aCallbacks */
                        loadFlags, ios);
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -1274,16 +1274,17 @@ class HTMLMediaElement::ChannelLoader fi
         getter_AddRefs(channel), aElement->mLoadingSrc,
         static_cast<Element*>(aElement), triggeringPrincipal, securityFlags,
         contentPolicyType,
         nullptr,  // aPerformanceStorage
         loadGroup,
         nullptr,  // aCallbacks
         nsICachingChannel::LOAD_BYPASS_LOCAL_CACHE_IF_BUSY |
             nsIChannel::LOAD_MEDIA_SNIFFER_OVERRIDES_CONTENT_TYPE |
+            nsIChannel::LOAD_CLASSIFY_URI |
             nsIChannel::LOAD_CALL_CONTENT_SNIFFERS);
 
     if (NS_FAILED(rv)) {
       // Notify load error so the element will try next resource candidate.
       aElement->NotifyLoadError(NS_LITERAL_CSTRING("Fail to create channel"));
       return;
     }
 
--- a/dom/html/HTMLTrackElement.cpp
+++ b/dom/html/HTMLTrackElement.cpp
@@ -308,21 +308,23 @@ void HTMLTrackElement::LoadResource(RefP
       [self = RefPtr<HTMLTrackElement>(this), uri, secFlags]() {
         if (!self->mListener) {
           // Shutdown got called, abort.
           return;
         }
         nsCOMPtr<nsIChannel> channel;
         nsCOMPtr<nsILoadGroup> loadGroup =
             self->OwnerDoc()->GetDocumentLoadGroup();
-        nsresult rv = NS_NewChannel(getter_AddRefs(channel), uri,
-                                    static_cast<Element*>(self), secFlags,
-                                    nsIContentPolicy::TYPE_INTERNAL_TRACK,
-                                    nullptr,  // PerformanceStorage
-                                    loadGroup);
+        nsresult rv = NS_NewChannel(
+            getter_AddRefs(channel), uri, static_cast<Element*>(self), secFlags,
+            nsIContentPolicy::TYPE_INTERNAL_TRACK,
+            nullptr,  // PerformanceStorage
+            loadGroup,
+            nullptr,  // aCallbacks
+            nsIRequest::LOAD_NORMAL | nsIChannel::LOAD_CLASSIFY_URI);
 
         NS_ENSURE_TRUE_VOID(NS_SUCCEEDED(rv));
 
         channel->SetNotificationCallbacks(self->mListener);
 
         LOG(LogLevel::Debug, ("opening webvtt channel"));
         rv = channel->AsyncOpen(self->mListener);
 
--- a/dom/jsurl/nsJSProtocolHandler.cpp
+++ b/dom/jsurl/nsJSProtocolHandler.cpp
@@ -777,16 +777,21 @@ nsJSChannel::SetLoadFlags(nsLoadFlags aL
     if (loadGroup) {
       nsLoadFlags loadGroupFlags;
       loadGroup->GetLoadFlags(&loadGroupFlags);
       loadGroupIsBackground = ((loadGroupFlags & LOAD_BACKGROUND) != 0);
     }
     bogusLoadBackground = !loadGroupIsBackground;
   }
 
+  // Classifying a javascript: URI doesn't help us, and requires
+  // NSS to boot, which we don't have in content processes.  See
+  // https://bugzilla.mozilla.org/show_bug.cgi?id=617838.
+  aLoadFlags &= ~LOAD_CLASSIFY_URI;
+
   // Since the javascript channel is never the actual channel that
   // any data is loaded through, don't ever set the
   // LOAD_DOCUMENT_URI flag on it, since that could lead to two
   // 'document channels' in the loadgroup if a javascript: URL is
   // loaded while a document is being loaded in the same window.
 
   // XXXbz this, and a whole lot of other hackery, could go away if we'd just
   // cancel the current document load on javascript: load start like IE does.
--- a/dom/media/ChannelMediaResource.cpp
+++ b/dom/media/ChannelMediaResource.cpp
@@ -716,16 +716,17 @@ void ChannelMediaResource::Resume() {
     }
   }
 }
 
 nsresult ChannelMediaResource::RecreateChannel() {
   MOZ_DIAGNOSTIC_ASSERT(!mClosed);
 
   nsLoadFlags loadFlags = nsICachingChannel::LOAD_BYPASS_LOCAL_CACHE_IF_BUSY |
+                          nsIChannel::LOAD_CLASSIFY_URI |
                           (mLoadInBackground ? nsIRequest::LOAD_BACKGROUND : 0);
 
   MediaDecoderOwner* owner = mCallback->GetMediaOwner();
   MOZ_DIAGNOSTIC_ASSERT(owner);
   dom::HTMLMediaElement* element = owner->GetMediaElement();
   MOZ_DIAGNOSTIC_ASSERT(element);
 
   nsCOMPtr<nsILoadGroup> loadGroup = element->GetDocumentLoadGroup();
--- a/dom/plugins/base/nsPluginHost.cpp
+++ b/dom/plugins/base/nsPluginHost.cpp
@@ -3089,25 +3089,25 @@ nsresult nsPluginHost::NewPluginURLStrea
 
   NS_ENSURE_TRUE(element, NS_ERROR_FAILURE);
 
   nsCOMPtr<nsIChannel> channel;
   // @arg loadgroup:
   // do not add this internal plugin's channel on the
   // load group otherwise this channel could be canceled
   // form |nsDocShell::OnLinkClickSync| bug 166613
-  rv = NS_NewChannel(
-      getter_AddRefs(channel), url, element,
-      nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_INHERITS |
-          nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL,
-      nsIContentPolicy::TYPE_OBJECT_SUBREQUEST,
-      nullptr,  // aPerformanceStorage
-      nullptr,  // aLoadGroup
-      listenerPeer,
-      nsIRequest::LOAD_NORMAL | nsIChannel::LOAD_BYPASS_SERVICE_WORKER);
+  rv = NS_NewChannel(getter_AddRefs(channel), url, element,
+                     nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_INHERITS |
+                         nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL,
+                     nsIContentPolicy::TYPE_OBJECT_SUBREQUEST,
+                     nullptr,  // aPerformanceStorage
+                     nullptr,  // aLoadGroup
+                     listenerPeer,
+                     nsIRequest::LOAD_NORMAL | nsIChannel::LOAD_CLASSIFY_URI |
+                         nsIChannel::LOAD_BYPASS_SERVICE_WORKER);
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (doc) {
     // And if it's a script allow it to execute against the
     // document's script context.
     nsCOMPtr<nsIScriptChannel> scriptChannel(do_QueryInterface(channel));
     if (scriptChannel) {
       scriptChannel->SetExecutionPolicy(nsIScriptChannel::EXECUTE_NORMAL);
--- a/dom/script/ScriptLoader.cpp
+++ b/dom/script/ScriptLoader.cpp
@@ -1259,17 +1259,18 @@ nsresult ScriptLoader::StartLoad(ScriptL
   }
   securityFlags |= nsILoadInfo::SEC_ALLOW_CHROME;
 
   nsCOMPtr<nsIChannel> channel;
   nsresult rv = NS_NewChannelWithTriggeringPrincipal(
       getter_AddRefs(channel), aRequest->mURI, context,
       aRequest->TriggeringPrincipal(), securityFlags, contentPolicyType,
       nullptr,  // aPerformanceStorage
-      loadGroup, prompter);
+      loadGroup, prompter,
+      nsIRequest::LOAD_NORMAL | nsIChannel::LOAD_CLASSIFY_URI);
 
   NS_ENSURE_SUCCESS(rv, rv);
 
   // snapshot the nonce at load start time for performing CSP checks
   if (contentPolicyType == nsIContentPolicy::TYPE_INTERNAL_SCRIPT ||
       contentPolicyType == nsIContentPolicy::TYPE_INTERNAL_MODULE) {
     nsCOMPtr<Element> element = do_QueryInterface(context);
     if (element && element->IsHTMLElement()) {
--- a/dom/security/nsCSPContext.cpp
+++ b/dom/security/nsCSPContext.cpp
@@ -1034,25 +1034,36 @@ nsresult nsCSPContext::SendReports(
                    aViolationEventInit.mSourceFile, aViolationEventInit.mSample,
                    aViolationEventInit.mLineNumber,
                    aViolationEventInit.mColumnNumber,
                    nsIScriptError::errorFlag);
       continue;  // don't return yet, there may be more URIs
     }
 
     // try to create a new channel for every report-uri
+    nsLoadFlags loadFlags =
+        nsIRequest::LOAD_NORMAL | nsIChannel::LOAD_CLASSIFY_URI;
     if (doc) {
       rv = NS_NewChannel(getter_AddRefs(reportChannel), reportURI, doc,
                          nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
-                         nsIContentPolicy::TYPE_CSP_REPORT);
+                         nsIContentPolicy::TYPE_CSP_REPORT,
+                         nullptr,  // aPerformanceStorage
+                         nullptr,  // aLoadGroup
+                         nullptr,  // aCallbacks
+                         loadFlags);
     } else {
       rv = NS_NewChannel(getter_AddRefs(reportChannel), reportURI,
                          mLoadingPrincipal,
                          nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
-                         nsIContentPolicy::TYPE_CSP_REPORT);
+                         nsIContentPolicy::TYPE_CSP_REPORT,
+                         nullptr,  // nsICookieSettings
+                         nullptr,  // PerformanceStorage
+                         nullptr,  // aLoadGroup
+                         nullptr,  // aCallbacks
+                         loadFlags);
     }
 
     if (NS_FAILED(rv)) {
       CSPCONTEXTLOG(("Could not create new channel for report URI %s",
                      reportURICstring.get()));
       continue;  // don't return yet, there may be more URIs
     }
 
--- a/dom/workers/ScriptLoader.cpp
+++ b/dom/workers/ScriptLoader.cpp
@@ -142,16 +142,17 @@ nsresult ChannelFromScriptURL(
   // If we have the document, use it. Unfortunately, for dedicated workers
   // 'parentDoc' ends up being the parent document, which is not the document
   // that we want to use. So make sure to avoid using 'parentDoc' in that
   // situation.
   if (parentDoc && parentDoc->NodePrincipal() != principal) {
     parentDoc = nullptr;
   }
 
+  aLoadFlags |= nsIChannel::LOAD_CLASSIFY_URI;
   uint32_t secFlags = aIsMainScript
                           ? nsILoadInfo::SEC_REQUIRE_SAME_ORIGIN_DATA_IS_BLOCKED
                           : nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_INHERITS;
 
   bool inheritAttrs = nsContentUtils::ChannelShouldInheritPrincipal(
       principal, uri, true /* aInheritForAboutBlank */,
       false /* aForceInherit */);
 
--- a/dom/xhr/XMLHttpRequestMainThread.cpp
+++ b/dom/xhr/XMLHttpRequestMainThread.cpp
@@ -2295,17 +2295,18 @@ void XMLHttpRequestMainThread::ChangeSta
 
 nsresult XMLHttpRequestMainThread::CreateChannel() {
   // When we are called from JS we can find the load group for the page,
   // and add ourselves to it. This way any pending requests
   // will be automatically aborted if the user leaves the page.
   nsCOMPtr<nsILoadGroup> loadGroup = GetLoadGroup();
 
   nsSecurityFlags secFlags;
-  nsLoadFlags loadFlags = nsIRequest::LOAD_BACKGROUND;
+  nsLoadFlags loadFlags =
+      nsIRequest::LOAD_BACKGROUND | nsIChannel::LOAD_CLASSIFY_URI;
   if (nsContentUtils::IsSystemPrincipal(mPrincipal)) {
     // When chrome is loading we want to make sure to sandbox any potential
     // result document. We also want to allow cross-origin loads.
     secFlags = nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL |
                nsILoadInfo::SEC_SANDBOXED;
   } else if (IsSystemXHR()) {
     // For pages that have appropriate permissions, we want to still allow
     // cross-origin loads, but make sure that the any potential result
--- a/image/imgLoader.cpp
+++ b/image/imgLoader.cpp
@@ -784,16 +784,17 @@ static nsresult NewImageChannel(
   }
 
   // Pass in a nullptr loadgroup because this is the underlying network
   // request. This request may be referenced by several proxy image requests
   // (possibly in different documents).
   // If all of the proxy requests are canceled then this request should be
   // canceled too.
   //
+  aLoadFlags |= nsIChannel::LOAD_CLASSIFY_URI;
 
   nsCOMPtr<nsINode> requestingNode = do_QueryInterface(aRequestingContext);
 
   nsSecurityFlags securityFlags =
       aCORSMode == imgIRequest::CORS_NONE
           ? nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_INHERITS
           : nsILoadInfo::SEC_REQUIRE_CORS_DATA_INHERITS;
   if (aCORSMode == imgIRequest::CORS_ANONYMOUS) {
--- a/layout/style/Loader.cpp
+++ b/layout/style/Loader.cpp
@@ -1431,27 +1431,31 @@ nsresult Loader::LoadSheet(SheetLoadData
   // and a principal. This is because of a case where the node is the document
   // being styled and the principal is the stylesheet (perhaps from a different
   // origin)  that is applying the styles.
   if (aLoadData->mRequestingNode && aLoadData->mLoaderPrincipal) {
     rv = NS_NewChannelWithTriggeringPrincipal(
         getter_AddRefs(channel), aLoadData->mURI, aLoadData->mRequestingNode,
         aLoadData->mLoaderPrincipal, securityFlags, contentPolicyType,
         nullptr,  // Performancestorage
-        loadGroup);
+        loadGroup,
+        nullptr,  // aCallbacks
+        nsIChannel::LOAD_NORMAL | nsIChannel::LOAD_CLASSIFY_URI);
   } else {
     // either we are loading something inside a document, in which case
     // we should always have a requestingNode, or we are loading something
     // outside a document, in which case the loadingPrincipal and the
     // triggeringPrincipal should always be the systemPrincipal.
     rv = NS_NewChannel(getter_AddRefs(channel), aLoadData->mURI,
                        nsContentUtils::GetSystemPrincipal(), securityFlags,
                        contentPolicyType, cookieSettings,
                        nullptr,  // aPerformanceStorage
-                       loadGroup);
+                       loadGroup,
+                       nullptr,  // aCallbacks
+                       nsIChannel::LOAD_NORMAL | nsIChannel::LOAD_CLASSIFY_URI);
   }
 
   if (NS_FAILED(rv)) {
 #ifdef DEBUG
     mSyncCallback = false;
 #endif
     LOG_ERROR(("  Failed to create channel"));
     SheetComplete(aLoadData, rv);
--- a/netwerk/base/nsBaseChannel.cpp
+++ b/netwerk/base/nsBaseChannel.cpp
@@ -327,17 +327,17 @@ void nsBaseChannel::ContinueHandleAsyncR
 
 void nsBaseChannel::ClassifyURI() {
   // For channels created in the child process, delegate to the parent to
   // classify URIs.
   if (!XRE_IsParentProcess()) {
     return;
   }
 
-  if (NS_ShouldClassifyChannel(this)) {
+  if (mLoadFlags & LOAD_CLASSIFY_URI) {
     RefPtr<nsChannelClassifier> classifier = new nsChannelClassifier(this);
     if (classifier) {
       classifier->Start();
     } else {
       Cancel(NS_ERROR_OUT_OF_MEMORY);
     }
   }
 }
--- a/netwerk/base/nsIChannel.idl
+++ b/netwerk/base/nsIChannel.idl
@@ -244,20 +244,20 @@ interface nsIChannel : nsIRequest
      * described in nsNetCID.h about NS_CONTENT_SNIFFER_CATEGORY.
      *
      * Note: Channels may ignore this flag; however, new channel implementations
      * should only do so with good reason.
      */
     const unsigned long LOAD_CALL_CONTENT_SNIFFERS = 1 << 21;
 
     /**
-     * This flag tells the channel to bypass URL classifier service check
-     * when opening the channel.
+     * This flag tells the channel to use URI classifier service to check
+     * the URI when opening the channel.
      */
-    const unsigned long LOAD_BYPASS_URL_CLASSIFIER = 1 << 22;
+    const unsigned long LOAD_CLASSIFY_URI = 1 << 22;
 
     /**
      * If this flag is set, the media-type content sniffer will be allowed
      * to override any server-set content-type. Otherwise it will only
      * be allowed to override "no content type" and application/octet-stream.
      */
     const unsigned long LOAD_MEDIA_SNIFFER_OVERRIDES_CONTENT_TYPE = 1 << 23;
 
--- a/netwerk/base/nsNetUtil.cpp
+++ b/netwerk/base/nsNetUtil.cpp
@@ -3006,80 +3006,16 @@ bool NS_IsOffline() {
   nsCOMPtr<nsIIOService> ios = do_GetIOService();
   if (ios) {
     ios->GetOffline(&offline);
     ios->GetConnectivity(&connectivity);
   }
   return offline || !connectivity;
 }
 
-/**
- * This function returns true if this channel should be classified by
- * the URL Classifier, false otherwise.
- *
- * The idea of the algorithm to determine if a channel should be
- * classified is based on:
- * 1. Channels created by non-privileged code should be classified.
- * 2. Top-level document’s channels, if loaded by privileged code
- *    (system principal), should be classified.
- * 3. Any other channel, created by privileged code, is considered safe.
- *
- * A bad/hacked/corrupted safebrowsing database, plus a mistakenly
- * classified critical channel (this may result from a bug in the exemption
- * rules or incorrect information being passed into) can cause serious
- * problems. For example, if the updater channel is classified and blocked
- * by the Safe Browsing, Firefox can't update itself, and there is no way to
- * recover from that.
- *
- * So two safeguards are added to ensure critical channels are never
- * automatically classified either because there is a bug in the algorithm
- * or the data in loadinfo is wrong.
- * 1. beConservative, this is set by ServiceRequest and we treat
- *    channel created for ServiceRequest as critical channels.
- * 2. nsIChannel::LOAD_BYPASS_URL_CLASSIFIER, channel's opener can use this
- *    flag to enforce bypassing the URL classifier check.
- */
-bool NS_ShouldClassifyChannel(nsIChannel *aChannel) {
-  nsLoadFlags loadFlags;
-  Unused << aChannel->GetLoadFlags(&loadFlags);
-  //  If our load flags dictate that we must let this channel through without
-  //  URL classification, obey that here without performing more checks.
-  if (loadFlags & nsIChannel::LOAD_BYPASS_URL_CLASSIFIER) {
-    return false;
-  }
-
-  nsCOMPtr<nsIHttpChannelInternal> httpChannel(do_QueryInterface(aChannel));
-  if (httpChannel) {
-    bool beConservative;
-    nsresult rv = httpChannel->GetBeConservative(&beConservative);
-
-    // beConservative flag, set by ServiceRequest to ensure channels that
-    // fetch update use conservative TLS setting, are used here to identify
-    // channels are critical to bypass classification. for channels don't
-    // support beConservative, continue to apply the exemption rules.
-    if (NS_SUCCEEDED(rv) && beConservative) {
-      return false;
-    }
-  }
-
-  nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
-  if (loadInfo) {
-    nsContentPolicyType type = loadInfo->GetExternalContentPolicyType();
-
-    // Skip classifying channel triggered by system unless it is a top-level
-    // load.
-    if (nsContentUtils::IsSystemPrincipal(loadInfo->TriggeringPrincipal()) &&
-        nsIContentPolicy::TYPE_DOCUMENT != type) {
-      return false;
-    }
-  }
-
-  return true;
-}
-
 namespace mozilla {
 namespace net {
 
 bool InScriptableRange(int64_t val) {
   return (val <= kJS_MAX_SAFE_INTEGER) && (val >= kJS_MIN_SAFE_INTEGER);
 }
 
 bool InScriptableRange(uint64_t val) { return val <= kJS_MAX_SAFE_UINTEGER; }
--- a/netwerk/base/nsNetUtil.h
+++ b/netwerk/base/nsNetUtil.h
@@ -932,21 +932,16 @@ nsresult NS_CompareLoadInfoAndLoadContex
  * network.http.referer.defaultPolicy.pbmode for private mode
  * network.http.referer.defaultPolicy.trackers.pbmode for third-party trackers
  * in private mode
  */
 uint32_t NS_GetDefaultReferrerPolicy(nsIHttpChannel *aChannel = nullptr,
                                      nsIURI *aURI = nullptr,
                                      bool privateBrowsing = false);
 
-/**
- * Return true if this channel should be classified by the URL classifier.
- */
-bool NS_ShouldClassifyChannel(nsIChannel *aChannel);
-
 namespace mozilla {
 namespace net {
 
 const static uint64_t kJS_MAX_SAFE_UINTEGER = +9007199254740991ULL;
 const static int64_t kJS_MIN_SAFE_INTEGER = -9007199254740991LL;
 const static int64_t kJS_MAX_SAFE_INTEGER = +9007199254740991LL;
 
 // Make sure a 64bit value can be captured by JS MAX_SAFE_INTEGER
--- a/netwerk/protocol/http/HttpBaseChannel.h
+++ b/netwerk/protocol/http/HttpBaseChannel.h
@@ -691,19 +691,16 @@ class HttpBaseChannel : public nsHashPro
   uint32_t mLoadedFromApplicationCache : 1;
   uint32_t mChannelIsForDownload : 1;
   uint32_t mTracingEnabled : 1;
   // True if timing collection is enabled
   uint32_t mTimingEnabled : 1;
   uint32_t mReportTiming : 1;
   uint32_t mAllowSpdy : 1;
   uint32_t mAllowAltSvc : 1;
-  // !!! This is also used by the URL classifier to exempt channels from
-  // classification. If this is changed or removed, make sure we also update
-  // NS_ShouldClassifyChannel accordingly !!!
   uint32_t mBeConservative : 1;
   uint32_t mTRR : 1;
   uint32_t mResponseTimeoutEnabled : 1;
   // A flag that should be false only if a cross-domain redirect occurred
   uint32_t mAllRedirectsSameOrigin : 1;
 
   // Is 1 if no redirects have occured or if all redirects
   // pass the Resource Timing timing-allow-check
--- a/netwerk/protocol/http/nsHttpChannel.cpp
+++ b/netwerk/protocol/http/nsHttpChannel.cpp
@@ -6594,17 +6594,17 @@ nsresult nsHttpChannel::BeginConnect() {
 
   // We may have been cancelled already, either by on-modify-request
   // listeners or load group observers; in that case, we should not send the
   // request to the server
   if (mCanceled) {
     return mStatus;
   }
 
-  if (!NS_ShouldClassifyChannel(this)) {
+  if (!(mLoadFlags & LOAD_CLASSIFY_URI)) {
     MaybeStartDNSPrefetch();
     return ContinueBeginConnectWithResult();
   }
 
   // We are about to do an async lookup to check if the URI is a
   // tracker. If yes, this channel will be canceled by channel classifier.
   // Chances are the lookup is not needed so CheckIsTrackerWithLocalTable()
   // will return an error and then we can BeginConnectActual() right away.
--- a/netwerk/test/unit/test_trackingProtection_annotateChannels.js
+++ b/netwerk/test/unit/test_trackingProtection_annotateChannels.js
@@ -115,16 +115,17 @@ function makeChannel(path, loadingPrinci
   } else {
     chan = NetUtil.newChannel({
       uri: path,
       loadUsingSystemPrincipal: true,
     });
   }
   chan.QueryInterface(Ci.nsIHttpChannel);
   chan.requestMethod = "GET";
+  chan.loadFlags |= Ci.nsIChannel.LOAD_CLASSIFY_URI;
   if (topWindowURI) {
     chan.QueryInterface(Ci.nsIHttpChannelInternal).setTopWindowURIIfUnknown(topWindowURI);
   }
   return chan;
 }
 
 var tests = [
   // Create the HTTP server.
@@ -241,17 +242,17 @@ var tests = [
     ];
     // We add the doPriorityTest test here so that it only gets injected in the
     // test list if we're not skipping over this test.
     tests.unshift(doPriorityTest);
     runTests();
   },
 
   // Annotations ON, system loading principal, topWinURI of example.com
-  // => trackers should not be de-prioritized
+  // => trackers should be de-prioritized
   function setupAnnotationsOnSystemPrincipal() {
     if (skipLowestPriority) {
       runTests();
       return;
     }
     if (runtime.processType == runtime.PROCESS_TYPE_DEFAULT) {
       Services.prefs.setBoolPref("privacy.trackingprotection.annotate_channels", true);
       Services.prefs.setBoolPref("privacy.trackingprotection.lower_network_priority", true);
@@ -272,26 +273,26 @@ var tests = [
         expectedTracking: false,
         expectedPriority: Ci.nsISupportsPriority.PRIORITY_NORMAL,
         expectedThrottleable: false, // ignored since tracking==false
       },
       {
         path: trackingOrigin + "/evil.css",
         loadingPrincipal: null, // system principal
         topWindowURI: defaultTopWindowURI,
-        expectedTracking: false,
-        expectedPriority: Ci.nsISupportsPriority.PRIORITY_NORMAL,
-        expectedThrottleable: false,
+        expectedTracking: true,
+        expectedPriority: Ci.nsISupportsPriority.PRIORITY_LOWEST,
+        expectedThrottleable: true,
       },
       {
         path: trackingOrigin + "/evil.js",
         loadingPrincipal: null, // system principal
         topWindowURI: defaultTopWindowURI,
-        expectedTracking: false,
-        expectedPriority: Ci.nsISupportsPriority.PRIORITY_NORMAL,
+        expectedTracking: true,
+        expectedPriority: Ci.nsISupportsPriority.PRIORITY_LOWEST,
         expectedThrottleable: true,
       },
     ];
     // We add the doPriorityTest test here so that it only gets injected in the
     // test list if we're not skipping over this test.
     tests.unshift(doPriorityTest);
     runTests();
   },
--- a/toolkit/components/telemetry/app/TelemetrySend.jsm
+++ b/toolkit/components/telemetry/app/TelemetrySend.jsm
@@ -1107,16 +1107,19 @@ var TelemetrySendImpl = {
 
     request.open("POST", url, true);
     request.overrideMimeType("text/plain");
     request.setRequestHeader("Content-Type", "application/json; charset=UTF-8");
     request.setRequestHeader("Date", Policy.now().toUTCString());
 
     this._pendingPingRequests.set(id, request);
 
+    // Prevent the request channel from running though URLClassifier (bug 1296802)
+    request.channel.loadFlags &= ~Ci.nsIChannel.LOAD_CLASSIFY_URI;
+
     const monotonicStartTime = Utils.monotonicNow();
     let deferred = PromiseUtils.defer();
 
     let onRequestFinished = (success, event) => {
       let onCompletion = () => {
         if (success) {
           deferred.resolve();
         } else {
--- a/toolkit/components/telemetry/pings/CoveragePing.jsm
+++ b/toolkit/components/telemetry/pings/CoveragePing.jsm
@@ -96,16 +96,19 @@ var CoveragePing = Object.freeze({
     request.mozBackgroundRequest = true;
     request.timeout = PING_SUBMISSION_TIMEOUT;
 
     request.open("PUT", endpoint, true);
     request.overrideMimeType("text/plain");
     request.setRequestHeader("Content-Type", "application/json; charset=UTF-8");
     request.setRequestHeader("Date", new Date().toUTCString());
 
+    // Prevent the request channel from running though URLClassifier (bug 1296802)
+    request.channel.loadFlags &= ~Ci.nsIChannel.LOAD_CLASSIFY_URI;
+
     let errorhandler = (event) => {
       let failure = event.type;
       log.error(`error making request to ${endpoint}: ${failure}`);
       deferred.reject(event);
     };
 
     request.onerror = errorhandler;
     request.ontimeout = errorhandler;
--- a/toolkit/components/url-classifier/UrlClassifierHashCompleter.jsm
+++ b/toolkit/components/url-classifier/UrlClassifierHashCompleter.jsm
@@ -446,22 +446,19 @@ HashCompleterRequest.prototype = {
       log("cancelling request to " + this.gethashUrl + " (timeout)\n");
       Services.telemetry.getKeyedHistogramById("URLCLASSIFIER_COMPLETE_TIMEOUT2").
         add(this.telemetryProvider, 1);
       this._channel.cancel(Cr.NS_BINDING_ABORTED);
     }
   },
 
   // Creates an nsIChannel for the request and fills the body.
-  // Enforce bypassing URL Classifier check because if the request is
-  // blocked, it means SafeBrowsing is malfunction.
   openChannel: function HCR_openChannel() {
     let loadFlags = Ci.nsIChannel.INHIBIT_CACHING |
-                    Ci.nsIChannel.LOAD_BYPASS_CACHE |
-                    Ci.nsIChannel.LOAD_BYPASS_URL_CLASSIFIER;
+                    Ci.nsIChannel.LOAD_BYPASS_CACHE;
 
     this.request = {
       url: this.gethashUrl,
       body: "",
     };
 
     if (this.isV4) {
       // As per spec, we add the request payload to the gethash url.
--- a/toolkit/components/url-classifier/nsUrlClassifierStreamUpdater.cpp
+++ b/toolkit/components/url-classifier/nsUrlClassifierStreamUpdater.cpp
@@ -121,22 +121,19 @@ void nsUrlClassifierStreamUpdater::Downl
 nsresult nsUrlClassifierStreamUpdater::FetchUpdate(
     nsIURI *aUpdateUrl, const nsACString &aRequestPayload, bool aIsPostRequest,
     const nsACString &aStreamTable) {
 #ifdef DEBUG
   LOG(("Fetching update %s from %s", aRequestPayload.Data(),
        aUpdateUrl->GetSpecOrDefault().get()));
 #endif
 
-  // SafeBrowsing update request should never be classified to make sure
-  // we can recover from a bad SafeBrowsing database.
   nsresult rv;
-  uint32_t loadFlags = nsIChannel::INHIBIT_CACHING |
-                       nsIChannel::LOAD_BYPASS_CACHE |
-                       nsIChannel::LOAD_BYPASS_URL_CLASSIFIER;
+  uint32_t loadFlags =
+      nsIChannel::INHIBIT_CACHING | nsIChannel::LOAD_BYPASS_CACHE;
   rv = NS_NewChannel(getter_AddRefs(mChannel), aUpdateUrl,
                      nsContentUtils::GetSystemPrincipal(),
                      nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
                      nsIContentPolicy::TYPE_OTHER,
                      nullptr,  // nsICookieSettings
                      nullptr,  // aPerformanceStorage
                      nullptr,  // aLoadGroup
                      this,     // aInterfaceRequestor
--- a/toolkit/components/url-classifier/tests/mochitest/bug_1281083.html
+++ b/toolkit/components/url-classifier/tests/mochitest/bug_1281083.html
@@ -1,11 +1,35 @@
 <html>
 <head>
 <title></title>
-</head>
-<body>
+
+<script type="text/javascript">
+
+var scriptItem = "untouched";
+
+function checkLoads() {
+  // Make sure the javascript did not load.
+  window.parent.is(scriptItem, "untouched", "Should not load bad javascript");
+
+  // Call parent.loadTestFrame again to test classification metadata in HTTP
+  // cache entries.
+  if (window.parent.firstLoad) {
+    window.parent.info("Reloading from cache...");
+    window.parent.firstLoad = false;
+    window.parent.loadTestFrame();
+    return;
+  }
+
+  // End (parent) test.
+  window.parent.SimpleTest.finish();
+}
+
+</script>
 
 <!-- Try loading from a malware javascript URI -->
-<script id="badscript" data-touched="not sure" src="http://bug1281083.example.com/tests/toolkit/components/url-classifier/tests/mochitest/evil.js" onload="this.dataset.touched = 'yes';" onerror="this.dataset.touched = 'no';"></script>
+<script type="text/javascript" src="http://bug1281083.example.com/tests/toolkit/components/url-classifier/tests/mochitest/evil.js"></script>
 
+</head>
+
+<body onload="checkLoads()">
 </body>
 </html>
--- a/toolkit/components/url-classifier/tests/mochitest/classifiedAnnotatedFrame.html
+++ b/toolkit/components/url-classifier/tests/mochitest/classifiedAnnotatedFrame.html
@@ -22,46 +22,105 @@ var badids = [
   "badimage1",
   "badimage2",
   "badframe1",
   "badframe2",
   "badmedia1",
   "badcss",
 ];
 
+function checkLoads() {
+  window.parent.is(
+    scriptItem1, "untouched", "Should not load tracking javascript");
+  window.parent.is(
+    scriptItem2, "untouched", "Should not load tracking javascript (2)");
+
+  window.parent.is(
+    imageItem1, "untouched", "Should not load tracking images");
+  window.parent.is(
+    imageItem2, "untouched", "Should not load tracking images (2)");
+
+  window.parent.is(
+    frameItem1, "untouched", "Should not load tracking iframes");
+  window.parent.is(
+    frameItem2, "untouched", "Should not load tracking iframes (2)");
+  window.parent.is(
+    mediaItem1, "error", "Should not load tracking videos");
+  window.parent.is(
+    xhrItem, "failed", "Should not load tracking XHRs");
+  window.parent.is(
+    fetchItem, "error", "Should not fetch from tracking URLs");
+
+  var elt = document.getElementById("styleCheck");
+  var style = document.defaultView.getComputedStyle(elt);
+  window.parent.isnot(
+    style.visibility, "hidden", "Should not load tracking css");
+
+  window.parent.is(window.document.blockedNodeByClassifierCount, badids.length,
+    "Should identify all tracking elements");
+
+  var blockedNodes = window.document.blockedNodesByClassifier;
+
+  // Make sure that every node in blockedNodes exists in the tree
+  // (that may not always be the case but do not expect any nodes to disappear
+  // from the tree here)
+  var allNodeMatch = true;
+  for (let i = 0; i < blockedNodes.length; i++) {
+    let nodeMatch = false;
+    for (let j = 0; j < badids.length && !nodeMatch; j++) {
+      nodeMatch = nodeMatch ||
+        (blockedNodes[i] == document.getElementById(badids[j]));
+    }
+
+    allNodeMatch = allNodeMatch && nodeMatch;
+  }
+  window.parent.ok(allNodeMatch,
+    "All annotated nodes are expected in the tree");
+
+  // Make sure that every node with a badid (see badids) is found in the
+  // blockedNodes. This tells us if we are neglecting to annotate
+  // some nodes
+  allNodeMatch = true;
+  for (let j = 0; j < badids.length; j++) {
+    let nodeMatch = false;
+    for (let i = 0; i < blockedNodes.length && !nodeMatch; i++) {
+      nodeMatch = nodeMatch ||
+        (blockedNodes[i] == document.getElementById(badids[j]));
+    }
+
+    if (!nodeMatch) {
+      console.log(badids[j] + " was not found in blockedNodes");
+    }
+    allNodeMatch = allNodeMatch && nodeMatch;
+  }
+  window.parent.ok(allNodeMatch,
+    "All tracking nodes are expected to be annotated as such");
+
+  // Unset prefs, etc.
+  window.parent.cleanup();
+  // End (parent) test.
+  window.parent.SimpleTest.finish();
+}
+
 var onloadCalled = false;
 var xhrFinished = false;
 var fetchFinished = false;
 var videoLoaded = false;
 function loaded(type) {
   if (type === "onload") {
       onloadCalled = true;
   } else if (type === "xhr") {
       xhrFinished = true;
   } else if (type === "fetch") {
       fetchFinished = true;
   } else if (type === "video") {
       videoLoaded = true;
   }
   if (onloadCalled && xhrFinished && fetchFinished && videoLoaded) {
-    var msg = new window.CustomEvent("OnLoadComplete", {
-      detail: JSON.stringify({
-        scriptItem,
-        scriptItem1,
-        scriptItem2,
-        imageItem1,
-        imageItem2,
-        frameItem1,
-        frameItem2,
-        xhrItem,
-        fetchItem,
-        mediaItem1,
-      }),
-    });
-    window.dispatchEvent(msg);
+      checkLoads();
   }
 }
 </script>
 
 <!-- Try loading from a tracking CSS URI -->
 <link id="badcss" rel="stylesheet" type="text/css" href="http://tracking.example.com/tests/toolkit/components/url-classifier/tests/mochitest/evil.css"></link>
 
 </head>
--- a/toolkit/components/url-classifier/tests/mochitest/mochitest.ini
+++ b/toolkit/components/url-classifier/tests/mochitest/mochitest.ini
@@ -9,18 +9,16 @@ support-files =
   evil.css
   evil.css^headers^
   evil.js
   evil.js^headers^
   evilWorker.js
   import.css
   raptor.jpg
   track.html
-  trackerFrame.html
-  trackerFrame.sjs
   trackingRequest.js
   trackingRequest.js^headers^
   unwantedWorker.js
   vp9.webm
   whitelistFrame.html
   workerFrame.html
   ping.sjs
   basic.vtt
@@ -35,17 +33,16 @@ support-files =
   seek.webm
   cache.sjs
   features.js
 
 [test_classifier.html]
 skip-if = (os == 'linux' && debug) #Bug 1199778
 [test_classifier_match.html]
 [test_classifier_worker.html]
-[test_classify_by_default.html]
 [test_classify_ping.html]
 skip-if = (verify && debug && (os == 'win' || os == 'mac'))
 [test_classify_track.html]
 [test_gethash.html]
 [test_bug1254766.html]
 [test_cachemiss.html]
 skip-if = verify
 [test_annotation_vs_TP.html]
--- a/toolkit/components/url-classifier/tests/mochitest/test_classified_annotations.html
+++ b/toolkit/components/url-classifier/tests/mochitest/test_classified_annotations.html
@@ -9,158 +9,42 @@
 <body>
 <p id="display"></p>
 <div id="content" style="display: none">
 </div>
 <pre id="test">
 
 <script class="testbody" type="text/javascript">
 
-var mainWindow = window.docShell.rootTreeItem.domWindow;
-var contentPage = "http://mochi.test:8888/chrome/toolkit/components/url-classifier/tests/mochitest/classifiedAnnotatedFrame.html";
-
 var Cc = SpecialPowers.Cc;
 var Ci = SpecialPowers.Ci;
 
-const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
 const {UrlClassifierTestUtils} = ChromeUtils.import("resource://testing-common/UrlClassifierTestUtils.jsm");
-const {TestUtils} = ChromeUtils.import("resource://testing-common/TestUtils.jsm");
-
-function testOnWindow() {
-  return new Promise((resolve, reject) => {
-    let win = mainWindow.OpenBrowserWindow();
-    win.addEventListener("load", function() {
-      TestUtils.topicObserved("browser-delayed-startup-finished",
-                              subject => subject == win).then(() => {
-        win.addEventListener("DOMContentLoaded", function onInnerLoad() {
-          if (win.content.location.href != contentPage) {
-            win.gBrowser.loadURI(contentPage, {
-              triggeringPrincipal: Services.scriptSecurityManager.createNullPrincipal({}),
-            });
-            return;
-          }
-          win.removeEventListener("DOMContentLoaded", onInnerLoad, true);
-
-          win.content.addEventListener("OnLoadComplete", function innerLoad2(e) {
-            win.content.removeEventListener("OnLoadComplete", innerLoad2);
-            SimpleTest.executeSoon(function() {
-              checkLoads(win, JSON.parse(e.detail));
-              resolve(win);
-            });
-          }, false, true);
-        }, true);
-        SimpleTest.executeSoon(function() {
-          win.gBrowser.loadURI(contentPage, {
-            triggeringPrincipal: Services.scriptSecurityManager.createNullPrincipal({}),
-          });
-        });
-      });
-    }, {capture: true, once: true});
-  });
-}
-
-var badids = [
-  "badscript1",
-  "badscript2",
-  "badimage1",
-  "badimage2",
-  "badframe1",
-  "badframe2",
-  "badmedia1",
-  "badcss",
-];
-
-function checkLoads(aWindow, aData) {
-  var win = aWindow.content;
-
-  is(aData.scriptItem1, "untouched", "Should not load tracking javascript");
-  is(aData.scriptItem2, "untouched", "Should not load tracking javascript (2)");
-
-  is(aData.imageItem1, "untouched", "Should not load tracking images");
-  is(aData.imageItem2, "untouched", "Should not load tracking images (2)");
-
-  is(aData.frameItem1, "untouched", "Should not load tracking iframes");
-  is(aData.frameItem2, "untouched", "Should not load tracking iframes (2)");
-  is(aData.mediaItem1, "error", "Should not load tracking videos");
-  is(aData.xhrItem, "failed", "Should not load tracking XHRs");
-  is(aData.fetchItem, "error", "Should not fetch from tracking URLs");
-
-  var elt = win.document.getElementById("styleCheck");
-  var style = win.document.defaultView.getComputedStyle(elt);
-  isnot(style.visibility, "hidden", "Should not load tracking css");
-
-  is(win.document.blockedNodeByClassifierCount, badids.length,
-    "Should identify all tracking elements");
-
-  var blockedNodes = win.document.blockedNodesByClassifier;
-
-  // Make sure that every node in blockedNodes exists in the tree
-  // (that may not always be the case but do not expect any nodes to disappear
-  // from the tree here)
-  var allNodeMatch = true;
-  for (let i = 0; i < blockedNodes.length; i++) {
-    let nodeMatch = false;
-    for (let j = 0; j < badids.length && !nodeMatch; j++) {
-      nodeMatch = nodeMatch ||
-        (blockedNodes[i] == win.document.getElementById(badids[j]));
-    }
-
-    allNodeMatch = allNodeMatch && nodeMatch;
-  }
-  ok(allNodeMatch, "All annotated nodes are expected in the tree");
-
-  // Make sure that every node with a badid (see badids) is found in the
-  // blockedNodes. This tells us if we are neglecting to annotate
-  // some nodes
-  allNodeMatch = true;
-  for (let j = 0; j < badids.length; j++) {
-    let nodeMatch = false;
-    for (let i = 0; i < blockedNodes.length && !nodeMatch; i++) {
-      nodeMatch = nodeMatch ||
-        (blockedNodes[i] == win.document.getElementById(badids[j]));
-    }
-
-    if (!nodeMatch) {
-      console.log(badids[j] + " was not found in blockedNodes");
-    }
-    allNodeMatch = allNodeMatch && nodeMatch;
-  }
-  ok(allNodeMatch, "All tracking nodes are expected to be annotated as such");
-
-  // End (parent) test.
-}
 
 function cleanup() {
   SpecialPowers.clearUserPref("privacy.trackingprotection.enabled");
   SpecialPowers.clearUserPref("channelclassifier.allowlist_example");
-
-  UrlClassifierTestUtils.cleanupTestTrackers();
 }
 
 SpecialPowers.pushPrefEnv(
   {"set": [["urlclassifier.trackingTable", "test-track-simple"]]},
   test);
 
-async function test() {
-  SimpleTest.registerCleanupFunction(cleanup);
-  await UrlClassifierTestUtils.addTestTrackers();
-
-  await SpecialPowers.setBoolPref("privacy.trackingprotection.enabled", true);
-  // Make sure chrome:// URIs are processed. This does not white-list
-  // any URIs unless 'https://allowlisted.example.com' is added in the
-  // permission manager (see test_allowlisted_annotations.html)
-  await SpecialPowers.setBoolPref("channelclassifier.allowlist_example", true);
-
-  await testOnWindow().then(function(aWindow) {
-    aWindow.close();
+function test() {
+  UrlClassifierTestUtils.addTestTrackers().then(() => {
+    SpecialPowers.setBoolPref("privacy.trackingprotection.enabled", true);
+    // Make sure chrome:// URIs are processed. This does not white-list
+    // any URIs unless 'https://allowlisted.example.com' is added in the
+    // permission manager (see test_allowlisted_annotations.html)
+    SpecialPowers.setBoolPref("channelclassifier.allowlist_example", true);
+    document.getElementById("testFrame").src = "classifiedAnnotatedFrame.html";
   });
-
-  SimpleTest.finish();
 }
 
 // Expected finish() call is in "classifiedAnnotatedFrame.html".
 SimpleTest.waitForExplicitFinish();
 
 </script>
 
 </pre>
+<iframe id="testFrame" width="100%" height="100%" onload=""></iframe>
 </body>
 </html>
--- a/toolkit/components/url-classifier/tests/mochitest/test_classifier_changetablepref.html
+++ b/toolkit/components/url-classifier/tests/mochitest/test_classifier_changetablepref.html
@@ -11,97 +11,52 @@
 <p id="display"></p>
 <div id="content" style="display: none">
 </div>
 <pre id="test">
 
 <script src="head.js"></script>
 <script class="testbody" type="text/javascript">
 
-var mainWindow = window.docShell.rootTreeItem.domWindow;
-var contentPage = "http://mochi.test:8888/chrome/toolkit/components/url-classifier/tests/mochitest/bug_1281083.html";
-
 const testTable = "moz-track-digest256";
 const UPDATE_URL = "http://mochi.test:8888/tests/toolkit/components/url-classifier/tests/mochitest/update.sjs";
 
 var Cc = SpecialPowers.Cc;
 var Ci = SpecialPowers.Ci;
 
-const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
-const {TestUtils} = ChromeUtils.import("resource://testing-common/TestUtils.jsm");
-
 var timer = Cc["@mozilla.org/timer;1"]
             .createInstance(Ci.nsITimer);
 
 // If default preference contain the table we want to test,
 // We should change test table to a different one.
 var trackingTables = SpecialPowers.getCharPref("urlclassifier.trackingTable").split(",");
 ok(!trackingTables.includes(testTable), "test table should not be in the preference");
 
 var listmanager = Cc["@mozilla.org/url-classifier/listmanager;1"].
                     getService(Ci.nsIUrlListManager);
 
 is(listmanager.getGethashUrl(testTable), "",
    "gethash url for test table should be empty before setting to preference");
 
-function checkLoads(aWindow, aBlocked) {
-  var win = aWindow.content;
-  is(win.document.getElementById("badscript").dataset.touched, aBlocked ? "no" : "yes", "Should not load tracking javascript");
-}
+function loadTestFrame() {
+  // gethash url of test table "moz-track-digest256" should be updated
+  // after setting preference.
+  var url = listmanager.getGethashUrl(testTable);
+  var expected = SpecialPowers.getCharPref("browser.safebrowsing.provider.mozilla.gethashURL");
 
-function testOnWindow() {
-  return new Promise((resolve, reject) => {
-    let win = mainWindow.OpenBrowserWindow();
-    win.addEventListener("load", function() {
-      TestUtils.topicObserved("browser-delayed-startup-finished",
-                              subject => subject == win).then(() => {
-        win.addEventListener("DOMContentLoaded", function onInnerLoad() {
-          if (win.content.location.href != contentPage) {
-            win.gBrowser.loadURI(contentPage, {
-              triggeringPrincipal: Services.scriptSecurityManager.createNullPrincipal({}),
-            });
-            return;
-          }
-          win.removeEventListener("DOMContentLoaded", onInnerLoad, true);
+  is(url, expected, testTable + " matches its gethash url");
 
-          win.content.addEventListener("load", function innerLoad2(e) {
-            win.content.removeEventListener("load", innerLoad2);
-            SimpleTest.executeSoon(function() {
-              resolve(win);
-            });
-          }, false, true);
-        }, true);
-        SimpleTest.executeSoon(function() {
-          win.gBrowser.loadURI(contentPage, {
-            triggeringPrincipal: Services.scriptSecurityManager.createNullPrincipal({}),
-          });
-        });
-      });
-    }, {capture: true, once: true});
-  });
-}
+  // Trigger update
+  listmanager.disableUpdate(testTable);
+  listmanager.enableUpdate(testTable);
+  listmanager.maybeToggleUpdateChecking();
 
-function setup() {
-  return new Promise(function(resolve, reject) {
-    // gethash url of test table "moz-track-digest256" should be updated
-    // after setting preference.
-    var url = listmanager.getGethashUrl(testTable);
-    var expected = SpecialPowers.getCharPref("browser.safebrowsing.provider.mozilla.gethashURL");
-
-    is(url, expected, testTable + " matches its gethash url");
-
-    // Trigger update
-    listmanager.disableUpdate(testTable);
-    listmanager.enableUpdate(testTable);
-    listmanager.maybeToggleUpdateChecking();
-
-    // We wait until "nextupdattime" was set as a signal that update is complete.
-    waitForUpdateSuccess(function() {
-      resolve();
-    });
+  // We wait until "nextupdattime" was set as a signal that update is complete.
+  waitForUpdateSuccess(function() {
+    document.getElementById("testFrame").src = "bug_1281083.html";
   });
 }
 
 function waitForUpdateSuccess(callback) {
   let nextupdatetime =
     SpecialPowers.getCharPref("browser.safebrowsing.provider.mozilla.nextupdatetime");
 
   if (nextupdatetime !== "1") {
@@ -109,37 +64,34 @@ function waitForUpdateSuccess(callback) 
     return;
   }
 
   timer.initWithCallback(function() {
     waitForUpdateSuccess(callback);
   }, 10, Ci.nsITimer.TYPE_ONE_SHOT);
 }
 
-async function runTest() {
-  // To make sure url is not blocked by an already blocked url.
-  // Here we use non-tracking.example.com as a tracked url.
-  // Since this table is only used in this bug, so it won't affect other testcases.
-  await addCompletionToServer(testTable, "bug1281083.example.com/", UPDATE_URL);
-
+function runTest() {
   /**
    * In this test we try to modify only urlclassifier.*Table preference to see if
    * url specified in the table will be blocked after update.
    */
-  await SpecialPowers.pushPrefEnv(
+  var pushPrefPromise = SpecialPowers.pushPrefEnv(
     {"set": [["urlclassifier.trackingTable", testTable]]});
 
-  await setup();
+  // To make sure url is not blocked by an already blocked url.
+  // Here we use non-tracking.example.com as a tracked url.
+  // Since this table is only used in this bug, so it won't affect other testcases.
+  var addCompletePromise =
+    addCompletionToServer(testTable, "bug1281083.example.com/", UPDATE_URL);
 
-  await testOnWindow().then(function(aWindow) {
-    checkLoads(aWindow, true);
-    aWindow.close();
-  });
-
-  SimpleTest.finish();
+  Promise.all([pushPrefPromise, addCompletePromise])
+    .then(() => {
+      loadTestFrame();
+    });
 }
 
 // Set nextupdatetime to 1 to trigger an update
 SpecialPowers.pushPrefEnv(
   {"set": [["privacy.trackingprotection.enabled", true],
            ["channelclassifier.allowlist_example", true],
            ["browser.safebrowsing.provider.mozilla.nextupdatetime", "1"],
            ["browser.safebrowsing.provider.mozilla.lists", testTable],
deleted file mode 100644
--- a/toolkit/components/url-classifier/tests/mochitest/test_classify_by_default.html
+++ /dev/null
@@ -1,98 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <meta charset="utf-8">
-  <title>Test for Bug 1442496</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1442496">Mozilla Bug 1442496</a>
-<p id="display"></p>
-<div id="content" style="display: none">
-</div>
-<pre id="test">
-
-<iframe id="testFrame1"></iframe>
-<iframe id="testFrame2"></iframe>
-
-<script class="testbody" type="text/javascript">
-
-// To add a request to test, add the request in trackerFrame.html
-// and the id of query string "?id=xxx" here.
-const trackersAll = [
-  "img-src",
-  "object-data",
-  "script-src",
-  "iframe-src",
-  "link-rel-stylesheet",
-  "link-rel-prefetch",
-  "video-src",
-  "track-src",
-  "ping",
-  "fetch",
-  "xmlhttprequest",
-  "send-beacon",
-];
-const trackerFrame = "http://itisatracker.org/tests/toolkit/components/url-classifier/tests/mochitest/trackerFrame.sjs";
-
-// This function ask the server to set the cookie
-function setup() {
-  return fetch(trackerFrame + "?init=" + trackersAll.length, {
-    credentials: "include",
-  });
-}
-
-function loadTestFrame(withcookie, frameId) {
-  return new Promise(resolve => {
-    let query = withcookie ? "with-cookie" : "without-cookie";
-    fetch(trackerFrame + "?callback=" + query, {
-      credentials: "include",
-    }).then(r => {
-      r.text().then((body) => {
-        let trackers_found = body.split(",");
-        for (let tracker of trackersAll) {
-          let description = "Tracker request " + tracker + "received " +
-            (withcookie ? "with" : "without") + " cookie";
-          ok(trackers_found.includes(tracker), description);
-        }
-        resolve();
-      });
-    });
-
-    let frame = document.getElementById(frameId);
-    frame.src = "trackerFrame.html";
-  });
-}
-
-async function runTests() {
-  await SpecialPowers.pushPrefEnv({set: [
-    [ "urlclassifier.trackingTable", "test-track-simple" ],
-    [ "privacy.trackingprotection.enabled", false ],
-    [ "privacy.trackingprotection.annotate_channels", false],
-    [ "browser.send_pings", true],
-  ]});
-
-  await setup();
-
-  await loadTestFrame(true, "testFrame1");
-
-  await SpecialPowers.pushPrefEnv({set: [
-    [ "network.cookie.cookieBehavior", 4],
-    [ "privacy.trackingprotection.annotate_channels", true],
-  ]});
-
-  await loadTestFrame(false, "testFrame2");
-
-  SimpleTest.finish();
-}
-
-SimpleTest.waitForExplicitFinish();
-runTests();
-
-</script>
-
-</pre>
-</body>
-</html>
--- a/toolkit/components/url-classifier/tests/mochitest/test_trackingprotection_bug1157081.html
+++ b/toolkit/components/url-classifier/tests/mochitest/test_trackingprotection_bug1157081.html
@@ -12,45 +12,42 @@
 <p id="display"></p>
 <div id="content" style="display: none">
 </div>
 <pre id="test">
 
 <script class="testbody" type="text/javascript">
 
 var mainWindow = window.docShell.rootTreeItem.domWindow;
-var contentPage = "http://mochi.test:8888/chrome/toolkit/components/url-classifier/tests/mochitest/classifiedAnnotatedPBFrame.html";
+var contentPage = "chrome://mochitests/content/chrome/toolkit/components/url-classifier/tests/mochitest/classifiedAnnotatedPBFrame.html";
 
-const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
+ChromeUtils.import("resource://gre/modules/Services.jsm");
 const {UrlClassifierTestUtils} = ChromeUtils.import("resource://testing-common/UrlClassifierTestUtils.jsm");
+const {BrowserTestUtils} = ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
 const {TestUtils} = ChromeUtils.import("resource://testing-common/TestUtils.jsm");
 
 function testOnWindow(aCallback) {
   var win = mainWindow.OpenBrowserWindow();
   win.addEventListener("load", function() {
     TestUtils.topicObserved("browser-delayed-startup-finished",
                             subject => subject == win).then(() => {
       win.addEventListener("DOMContentLoaded", function onInnerLoad() {
         if (win.content.location.href != contentPage) {
-          win.gBrowser.loadURI(contentPage, {
-            triggeringPrincipal: Services.scriptSecurityManager.createNullPrincipal({}),
-          });
+          BrowserTestUtils.loadURI(win.gBrowser, contentPage);
           return;
         }
         win.removeEventListener("DOMContentLoaded", onInnerLoad, true);
 
         win.content.addEventListener("load", function innerLoad2() {
           win.content.removeEventListener("load", innerLoad2);
           SimpleTest.executeSoon(function() { aCallback(win); });
         }, false, true);
       }, true);
       SimpleTest.executeSoon(function() {
-        win.gBrowser.loadURI(contentPage, {
-          triggeringPrincipal: Services.scriptSecurityManager.createNullPrincipal({}),
-        });
+        BrowserTestUtils.loadURI(win.gBrowser, contentPage);
       });
     });
   }, {capture: true, once: true});
 }
 
 var badids = [
   "badscript",
 ];
deleted file mode 100644
--- a/toolkit/components/url-classifier/tests/mochitest/trackerFrame.html
+++ /dev/null
@@ -1,72 +0,0 @@
-<!DOCTYPE HTML>
-<!-- Any copyright is dedicated to the Public Domain.
-     http://creativecommons.org/publicdomain/zero/1.0/ -->
-<html>
-<head>
-<title></title>
-</head>
-<body>
-
-<!--NewImageChannel-->
-<img src="http://itisatracker.org/tests/toolkit/components/url-classifier/tests/mochitest/trackerFrame.sjs?id=img-src">
-
-<!--nsObjectLoadingContent::OpenChannel-->
-<object data="http://itisatracker.org/tests/toolkit/components/url-classifier/tests/mochitest/trackerFrame.sjs?id=object-data"></object>
-
-<!--ScriptLoader::StartLoad-->
-<script src="http://itisatracker.org/tests/toolkit/components/url-classifier/tests/mochitest/trackerFrame.sjs?id=script-src"></script>
-
-<!--nsDocShell::DoURILoad-->
-<iframe src="http://itisatracker.org/tests/toolkit/components/url-classifier/tests/mochitest/trackerFrame.sjs?id=iframe-src"></iframe>
-
-<!--Loader::LoadSheet-->
-<link rel="stylesheet" href="http://itisatracker.org/tests/toolkit/components/url-classifier/tests/mochitest/trackerFrame.sjs?id=link-rel-stylesheet" />
-
-<!--nsPrefetchNode::OpenChannel-->
-<link rel="prefetch" href="http://itisatracker.org/tests/toolkit/components/url-classifier/tests/mochitest/trackerFrame.sjs?id=link-rel-prefetch" />
-
-<!--HTMLMediaElement::ChannelLoader::LoadInternal-->
-<video src="http://itisatracker.org/tests/toolkit/components/url-classifier/tests/mochitest/trackerFrame.sjs?id=video-src">
-</video>
-
-<video src="http://mochi.test:8888/basic.vtt", crossorigin=use-credentials>
-  <track src="http://itisatracker.org/tests/toolkit/components/url-classifier/tests/mochitest/trackerFrame.sjs?id=track-src" ></track>
-</video>
-
-<!--SendPing-->
-<a ping="http://itisatracker.org/tests/toolkit/components/url-classifier/tests/mochitest/trackerFrame.sjs?id=ping" id="a-ping" href="#"></a>
-<script>
-  (function() {
-    document.getElementById("a-ping").click();
-  })();
-</script>
-
-<script>
-
-// FetchDriver::HttpFetch
-(function() {
-  try {
-    fetch(new Request("http://itisatracker.org/tests/toolkit/components/url-classifier/tests/mochitest/trackerFrame.sjs?id=fetch"), {
-      credentials: "include",
-    });
-  } catch (err) {
-    console.log(err);
-  }
-})();
-
-// XMLHttpRequestMainThread::CreateChannel
-(function() {
-    var xhr = new XMLHttpRequest();
-    xhr.open("GET", "http://itisatracker.org/tests/toolkit/components/url-classifier/tests/mochitest/trackerFrame.sjs?id=xmlhttprequest");
-    xhr.withCredentials = true;
-    xhr.send();
-})();
-
-// Navigator::SendBeaconInternal
-(function() {
-    navigator.sendBeacon("http://itisatracker.org/tests/toolkit/components/url-classifier/tests/mochitest/trackerFrame.sjs?id=send-beacon");
-})();
-
-</script>
-</body>
-</html>
deleted file mode 100644
--- a/toolkit/components/url-classifier/tests/mochitest/trackerFrame.sjs
+++ /dev/null
@@ -1,76 +0,0 @@
-/* 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/. */
-
-Components.utils.importGlobalProperties(["URLSearchParams"]);
-
-const stateTotalRequests = "total-request";
-const stateCallback = "callback-response";
-const stateTrackersWithCookie = "trackers-with-cookie";
-const stateTrackersWithoutCookie = "trackers-without-cookie";
-const stateReceivedTrackers = "received-trackers";
-const stateResponseType = "response-tracker-with-cookie";
-
-function reset()
-{
-  setState(stateCallback, "");
-  setState(stateTrackersWithCookie, "");
-  setState(stateTrackersWithoutCookie, "");
-  setState(stateReceivedTrackers, "");
-  setState(stateResponseType, "");
-}
-
-function handleRequest(aRequest, aResponse)
-{
-  let params = new URLSearchParams(aRequest.queryString);
-
-  // init the server and tell the server the total number requests to process
-  // server set the cookie
-  if (params.has("init")) {
-    setState(stateTotalRequests, params.get("init"));
-
-    aResponse.setStatusLine(aRequest.httpVersion, 200);
-    aResponse.setHeader("Content-Type", "text/plain", false);
-
-    // Prepare the cookie
-    aResponse.setHeader("Set-Cookie", "cookie=1234");
-    aResponse.setHeader("Access-Control-Allow-Origin", aRequest.getHeader("Origin"), false);
-    aResponse.setHeader("Access-Control-Allow-Credentials","true", false);
-    aResponse.write("begin-test");
-  // register the callback response, the response will be fired after receiving
-  // all the request
-  } else if (params.has("callback")) {
-    aResponse.processAsync();
-    aResponse.setHeader("Content-Type", "text/plain", false);
-    aResponse.setHeader("Access-Control-Allow-Origin", aRequest.getHeader("Origin"), false);
-    aResponse.setHeader("Access-Control-Allow-Credentials","true", false);
-
-    setState(stateResponseType, params.get("callback"));
-    setObjectState(stateCallback, aResponse);
-  } else {
-    let count = parseInt(getState(stateReceivedTrackers) || 0) + 1;
-    setState(stateReceivedTrackers, count.toString());
-
-    let state = "";
-    if (aRequest.hasHeader("Cookie")) {
-      state = stateTrackersWithCookie;
-    } else {
-      state = stateTrackersWithoutCookie;
-    }
-
-    let ids = params.get("id").concat(",", getState(state));
-    setState(state, ids);
-
-    if (getState(stateTotalRequests) == getState(stateReceivedTrackers)) {
-      getObjectState(stateCallback, r => {
-        if (getState(stateResponseType) == "with-cookie") {
-          r.write(getState(stateTrackersWithCookie));
-        } else {
-          r.write(getState(stateTrackersWithoutCookie));
-        }
-        r.finish();
-        reset();
-      });
-    }
-  }
-}
deleted file mode 100644
--- a/toolkit/components/url-classifier/tests/unit/test_shouldclassify.js
+++ /dev/null
@@ -1,137 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
-   http://creativecommons.org/publicdomain/zero/1.0/
-*/
-
-"use strict";
-
-const {NetUtil} = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
-const {UrlClassifierTestUtils} = ChromeUtils.import("resource://testing-common/UrlClassifierTestUtils.jsm");
-
-const defaultTopWindowURI = NetUtil.newURI("http://www.example.com/");
-
-var httpServer;
-var normalOrigin, trackingOrigin;
-
-// ShouldClassify algorithm uses the following parameters:
-// 1. Ci.nsIChannel.LOAD_ BYPASS_URL_CLASSIFIER loadflags
-// 2. Content type
-// 3. triggering principal
-// 4. be Conservative
-// We test are the combinations here to make sure the algorithm is correct
-
-const PARAM_LOAD_BYPASS_URL_CLASSIFIER    = 1 << 0;
-const PARAM_CONTENT_POLICY_TYPE_DOCUMENT  = 1 << 1;
-const PARAM_TRIGGERING_PRINCIPAL_SYSTEM   = 1 << 2;
-const PARAM_CAP_BE_CONSERVATIVE           = 1 << 3;
-const PARAM_MAX                           = 1 << 4;
-
-function getParameters(bitFlags) {
-  var params = {
-    loadFlags: Ci.nsIRequest.LOAD_NORMAL,
-    contentType: Ci.nsIContentPolicy.TYPE_OTHER,
-    system: false,
-    beConservative: false,
-  };
-
-  if (bitFlags & PARAM_TRIGGERING_PRINCIPAL_SYSTEM) {
-    params.loadFlags = Ci.nsIChannel.LOAD_BYPASS_URL_CLASSIFIER;
-  }
-
-  if (bitFlags & PARAM_CONTENT_POLICY_TYPE_DOCUMENT) {
-    params.contentType = Ci.nsIContentPolicy.TYPE_DOCUMENT;
-  }
-
-  if (bitFlags & PARAM_TRIGGERING_PRINCIPAL_SYSTEM) {
-    params.system = true;
-  }
-
-  if (bitFlags & PARAM_CAP_BE_CONSERVATIVE) {
-    params.beConservative = true;
-  }
-
-  return params;
-}
-
-function getExpectedResult(params) {
-  if (params.loadFlags & Ci.nsIChannel.LOAD_BYPASS_URL_CLASSIFIER) {
-    return false;
-  }
-  if (params.beConservative) {
-    return false;
-  }
-  if (params.system &&
-      params.contentType != Ci.nsIContentPolicy.TYPE_DOCUMENT) {
-    return false;
-  }
-
-  return true;
-}
-
-function setupHttpServer() {
-  httpServer = new HttpServer();
-  httpServer.start(-1);
-  httpServer.identity.setPrimary("http", "tracking.example.org", httpServer.identity.primaryPort);
-  httpServer.identity.add("http", "example.org", httpServer.identity.primaryPort);
-  normalOrigin = "http://localhost:" + httpServer.identity.primaryPort;
-  trackingOrigin = "http://tracking.example.org:" + httpServer.identity.primaryPort;
-}
-
-function setupChannel(params) {
-  var channel;
-
-  if (params.system) {
-    channel = NetUtil.newChannel({
-      uri: trackingOrigin + "/evil.js",
-      loadUsingSystemPrincipal: true,
-      contentPolicyType: params.contentType,
-    });
-  } else {
-    let principal =
-      Services.scriptSecurityManager.createCodebasePrincipal(NetUtil.newURI(trackingOrigin), {});
-    channel = NetUtil.newChannel({
-      uri: trackingOrigin + "/evil.js",
-      loadingPrincipal: principal,
-      securityFlags: Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
-      contentPolicyType: params.contentType,
-    });
-  }
-
-  channel.QueryInterface(Ci.nsIHttpChannel);
-  channel.requestMethod = "GET";
-  channel.loadFlags |= params.loadFlags;
-  channel.QueryInterface(Ci.nsIHttpChannelInternal).setTopWindowURIIfUnknown(defaultTopWindowURI);
-  channel.QueryInterface(Ci.nsIHttpChannelInternal).beConservative = params.beConservative;
-
-  return channel;
-}
-
-add_task(async function testShouldClassify() {
-  Services.prefs.setBoolPref("privacy.trackingprotection.annotate_channels", true);
-
-  setupHttpServer();
-
-  await UrlClassifierTestUtils.addTestTrackers();
-
-  for (let i = 0; i < PARAM_MAX; i++) {
-    let params = getParameters(i);
-    let channel = setupChannel(params);
-
-    await new Promise(resolve => {
-      channel.asyncOpen({
-        onStartRequest: (request, context) => {
-          Assert.equal(request.QueryInterface(Ci.nsIHttpChannel).isTrackingResource,
-                       getExpectedResult(params));
-          request.cancel(Cr.NS_ERROR_ABORT);
-          resolve();
-        },
-
-        onDataAvailable: (request, context, stream, offset, count) => {},
-        onStopRequest: (request, context, status) => {},
-      });
-    });
-  }
-
-  UrlClassifierTestUtils.cleanupTestTrackers();
-
-  httpServer.stop(do_test_finished);
-});
--- a/toolkit/components/url-classifier/tests/unit/xpcshell.ini
+++ b/toolkit/components/url-classifier/tests/unit/xpcshell.ini
@@ -21,9 +21,8 @@ support-files =
 [test_streamupdater.js]
 [test_digest256.js]
 [test_listmanager.js]
 [test_pref.js]
 [test_malwaretable_pref.js]
 [test_safebrowsing_protobuf.js]
 [test_platform_specific_threats.js]
 [test_features.js]
-[test_shouldclassify.js]