author | Francois Marier <francois@mozilla.com> |
Thu, 11 Jun 2015 21:48:17 +1200 | |
changeset 248287 | 8cf841f9a42e74177747f90bd7917400dd4469ff |
parent 248286 | 6ce98e37b52e63b3d1cb452e9bb61edc164f6ddb |
child 248288 | 1c9478931a9463d292e0d5dc5a20097be06f38f8 |
push id | 28893 |
push user | kwierso@gmail.com |
push date | Fri, 12 Jun 2015 00:02:58 +0000 |
treeherder | autoland@8cf9d3e497f9 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | sworkman |
bugs | 1157081 |
milestone | 41.0a1 |
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
|
--- a/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp +++ b/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp @@ -1200,17 +1200,17 @@ NS_IMETHODIMP nsUrlClassifierDBService::Classify(nsIPrincipal* aPrincipal, bool aTrackingProtectionEnabled, nsIURIClassifierCallback* c, bool* result) { NS_ENSURE_ARG(aPrincipal); NS_ENSURE_TRUE(gDbBackgroundThread, NS_ERROR_NOT_INITIALIZED); - if (!(mCheckMalware || mCheckPhishing)) { + if (!(mCheckMalware || mCheckPhishing || aTrackingProtectionEnabled)) { *result = false; return NS_OK; } nsRefPtr<nsUrlClassifierClassifyCallback> callback = new nsUrlClassifierClassifyCallback(c, mCheckMalware, mCheckPhishing, mCheckTracking); if (!callback) return NS_ERROR_OUT_OF_MEMORY;
--- a/toolkit/components/url-classifier/tests/mochitest/chrome.ini +++ b/toolkit/components/url-classifier/tests/mochitest/chrome.ini @@ -4,8 +4,9 @@ support-files = allowlistAnnotatedFrame.html classifiedAnnotatedFrame.html classifiedAnnotatedPBFrame.html [test_lookup_system_principal.html] [test_classified_annotations.html] [test_allowlisted_annotations.html] [test_privatebrowsing_trackingprotection.html] +[test_trackingprotection_bug1157081.html]
copy from toolkit/components/url-classifier/tests/mochitest/test_privatebrowsing_trackingprotection.html copy to toolkit/components/url-classifier/tests/mochitest/test_trackingprotection_bug1157081.html --- a/toolkit/components/url-classifier/tests/mochitest/test_privatebrowsing_trackingprotection.html +++ b/toolkit/components/url-classifier/tests/mochitest/test_trackingprotection_bug1157081.html @@ -1,14 +1,14 @@ <!DOCTYPE HTML> <!-- Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ --> <html> <head> - <title>Test Tracking Protection in Private Browsing mode</title> + <title>Test Tracking Protection with and without Safe Browsing (Bug #1157081)</title> <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"> </head> <body> <p id="display"></p> <div id="content" style="display: none"> </div> @@ -33,18 +33,18 @@ function whenDelayedStartupFinished(aWin Services.obs.addObserver(function observer(aSubject, aTopic) { if (aWindow == aSubject) { Services.obs.removeObserver(observer, aTopic); setTimeout(aCallback, 0); } }, "browser-delayed-startup-finished", false); } -function testOnWindow(aPrivate, aCallback) { - var win = mainWindow.OpenBrowserWindow({private: aPrivate}); +function testOnWindow(aCallback) { + var win = mainWindow.OpenBrowserWindow(); win.addEventListener("load", function onLoad() { win.removeEventListener("load", onLoad, false); whenDelayedStartupFinished(win, function() { win.addEventListener("DOMContentLoaded", function onInnerLoad() { if (win.content.location.href != contentPage) { win.gBrowser.loadURI(contentPage); return; } @@ -63,63 +63,22 @@ function testOnWindow(aPrivate, aCallbac // Add some URLs to the tracking database var testData = "tracking.example.com/"; var testUpdate = "n:1000\ni:test-track-simple\nad:1\n" + "a:524:32:" + testData.length + "\n" + testData; var badids = [ - "badscript", - "badimage", - "badcss" + "badscript" ]; function checkLoads(aWindow, aBlocked) { var win = aWindow.content; is(win.document.getElementById("badscript").dataset.touched, aBlocked ? "no" : "yes", "Should not load tracking javascript"); - is(win.document.getElementById("badimage").dataset.touched, aBlocked ? "no" : "yes", "Should not load tracking images"); - - var elt = win.document.getElementById("styleCheck"); - var style = win.document.defaultView.getComputedStyle(elt, ""); - isnot(style.visibility, aBlocked ? "hidden" : "", "Should not load tracking css"); - - is(win.document.blockedTrackingNodeCount, aBlocked ? badids.length : 0, "Should identify all tracking elements"); - - var blockedTrackingNodes = win.document.blockedTrackingNodes; - - // Make sure that every node in blockedTrackingNodes 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 (var i = 0; i < blockedTrackingNodes.length; i++) { - var nodeMatch = false; - for (var j = 0; j < badids.length && !nodeMatch; j++) { - nodeMatch = nodeMatch || - (blockedTrackingNodes[i] == win.document.getElementById(badids[j])); - } - - allNodeMatch = allNodeMatch && nodeMatch; - } - is(allNodeMatch, true, "All annotated nodes are expected in the tree"); - - // Make sure that every node with a badid (see badids) is found in the - // blockedTrackingNodes. This tells us if we are neglecting to annotate - // some nodes - allNodeMatch = true; - for (var j = 0; j < badids.length; j++) { - var nodeMatch = false; - for (var i = 0; i < blockedTrackingNodes.length && !nodeMatch; i++) { - nodeMatch = nodeMatch || - (blockedTrackingNodes[i] == win.document.getElementById(badids[j])); - } - - allNodeMatch = allNodeMatch && nodeMatch; - } - is(allNodeMatch, aBlocked, "All tracking nodes are expected to be annotated as such"); } var dbService = Cc["@mozilla.org/url-classifier/dbservice;1"] .getService(Ci.nsIUrlClassifierDBService); function doUpdate(update) { var listener = { QueryInterface: function(iid) @@ -133,49 +92,44 @@ function doUpdate(update) { updateUrlRequested: function(url) { }, streamFinished: function(status) { }, updateError: function(errorCode) { ok(false, "Couldn't update classifier."); // Abort test. SimpleTest.finish(); }, updateSuccess: function(requestedTimeout) { - // Normal mode, with the pref (trackers should be loaded) - testOnWindow(false, function(aWindow) { - checkLoads(aWindow, false); + // Safe Browsing turned OFF, tracking protection should work nevertheless + testOnWindow(function(aWindow) { + checkLoads(aWindow, true); aWindow.close(); - // Private Browsing, with the pref (trackers should be blocked) - testOnWindow(true, function(aWindow) { + // Safe Browsing turned ON, tracking protection should still work + SpecialPowers.setBoolPref("browser.safebrowsing.enabled", true); + testOnWindow(function(aWindow) { checkLoads(aWindow, true); aWindow.close(); - - // Private Browsing, without the pref (trackers should be loaded) - SpecialPowers.setBoolPref("privacy.trackingprotection.pbmode.enabled", false); - testOnWindow(true, function(aWindow) { - checkLoads(aWindow, false); - aWindow.close(); - SimpleTest.finish(); - }); + SimpleTest.finish(); }); }); } }; dbService.beginUpdate(listener, "test-track-simple", ""); dbService.beginStream("", ""); dbService.updateStream(update); dbService.finishStream(); dbService.finishUpdate(); } SpecialPowers.pushPrefEnv( {"set" : [["urlclassifier.trackingTable", "test-track-simple"], - ["privacy.trackingprotection.enabled", false], - ["privacy.trackingprotection.pbmode.enabled", true], + ["privacy.trackingprotection.enabled", true], + ["browser.safebrowsing.malware.enabled", false], + ["browser.safebrowsing.enabled", false], ["channelclassifier.allowlist_example", true]]}, function() { doUpdate(testUpdate); }); SimpleTest.waitForExplicitFinish(); </script> </pre>