зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 4 changesets (bug 1451307) for failing android at toolkit/components/url-classifier/tests/mochitest/test_cachemiss.html
Backed out changeset 9e0246c2f62f (bug 1451307) Backed out changeset 12ea607734b1 (bug 1451307) Backed out changeset 7adc755a4229 (bug 1451307) Backed out changeset 9f8135caee4f (bug 1451307) --HG-- rename : browser/base/content/test/trackingUI/benignPage.html => browser/base/content/test/general/benignPage.html rename : browser/base/content/test/trackingUI/browser_trackingUI_1.js => browser/base/content/test/general/browser_trackingUI_1.js rename : browser/base/content/test/trackingUI/browser_trackingUI_2.js => browser/base/content/test/general/browser_trackingUI_2.js rename : browser/base/content/test/trackingUI/browser_trackingUI_3.js => browser/base/content/test/general/browser_trackingUI_3.js rename : browser/base/content/test/trackingUI/browser_trackingUI_4.js => browser/base/content/test/general/browser_trackingUI_4.js rename : browser/base/content/test/trackingUI/browser_trackingUI_5.js => browser/base/content/test/general/browser_trackingUI_5.js rename : browser/base/content/test/trackingUI/browser_trackingUI_6.js => browser/base/content/test/general/browser_trackingUI_6.js rename : browser/base/content/test/trackingUI/browser_trackingUI_telemetry.js => browser/base/content/test/general/browser_trackingUI_telemetry.js rename : browser/base/content/test/trackingUI/file_trackingUI_6.html => browser/base/content/test/general/file_trackingUI_6.html rename : browser/base/content/test/trackingUI/file_trackingUI_6.js => browser/base/content/test/general/file_trackingUI_6.js rename : browser/base/content/test/trackingUI/file_trackingUI_6.js^headers^ => browser/base/content/test/general/file_trackingUI_6.js^headers^ rename : browser/base/content/test/trackingUI/trackingPage.html => browser/base/content/test/general/trackingPage.html
This commit is contained in:
Родитель
802b32e3a2
Коммит
267e2b904c
|
@ -89,9 +89,6 @@ with Files("test/tabs/**"):
|
|||
with Files("test/touch/**"):
|
||||
BUG_COMPONENT = ("Firefox", "General")
|
||||
|
||||
with Files("test/trackingUI/**"):
|
||||
BUG_COMPONENT = ("Firefox", "Tracking Protection")
|
||||
|
||||
with Files("test/urlbar/**"):
|
||||
BUG_COMPONENT = ("Firefox", "Address Bar")
|
||||
|
||||
|
|
|
@ -460,6 +460,44 @@ support-files =
|
|||
[browser_testOpenNewRemoteTabsFromNonRemoteBrowsers.js]
|
||||
run-if = e10s
|
||||
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
|
||||
[browser_trackingUI_1.js]
|
||||
tags = trackingprotection
|
||||
support-files =
|
||||
trackingPage.html
|
||||
benignPage.html
|
||||
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
|
||||
[browser_trackingUI_2.js]
|
||||
tags = trackingprotection
|
||||
support-files =
|
||||
trackingPage.html
|
||||
benignPage.html
|
||||
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
|
||||
[browser_trackingUI_3.js]
|
||||
tags = trackingprotection
|
||||
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
|
||||
[browser_trackingUI_4.js]
|
||||
tags = trackingprotection
|
||||
support-files =
|
||||
trackingPage.html
|
||||
benignPage.html
|
||||
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
|
||||
[browser_trackingUI_5.js]
|
||||
tags = trackingprotection
|
||||
support-files =
|
||||
trackingPage.html
|
||||
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
|
||||
[browser_trackingUI_6.js]
|
||||
tags = trackingprotection
|
||||
support-files =
|
||||
file_trackingUI_6.html
|
||||
file_trackingUI_6.js
|
||||
file_trackingUI_6.js^headers^
|
||||
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
|
||||
[browser_trackingUI_telemetry.js]
|
||||
tags = trackingprotection
|
||||
support-files =
|
||||
trackingPage.html
|
||||
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
|
||||
[browser_typeAheadFind.js]
|
||||
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
|
||||
[browser_unknownContentType_title.js]
|
||||
|
|
|
@ -7,9 +7,15 @@
|
|||
* See also Bugs 1175327, 1043801, 1178985
|
||||
*/
|
||||
|
||||
const PREF = "privacy.trackingprotection.enabled";
|
||||
const PB_PREF = "privacy.trackingprotection.pbmode.enabled";
|
||||
const BENIGN_PAGE = "http://tracking.example.org/browser/browser/base/content/test/general/benignPage.html";
|
||||
const TRACKING_PAGE = "http://tracking.example.org/browser/browser/base/content/test/general/trackingPage.html";
|
||||
var TrackingProtection = null;
|
||||
var tabbrowser = null;
|
||||
|
||||
var {UrlClassifierTestUtils} = ChromeUtils.import("resource://testing-common/UrlClassifierTestUtils.jsm", {});
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
TrackingProtection = tabbrowser = null;
|
||||
UrlClassifierTestUtils.cleanupTestTrackers();
|
|
@ -4,9 +4,15 @@
|
|||
* See also Bugs 1175327, 1043801, 1178985.
|
||||
*/
|
||||
|
||||
const PREF = "privacy.trackingprotection.enabled";
|
||||
const PB_PREF = "privacy.trackingprotection.pbmode.enabled";
|
||||
const BENIGN_PAGE = "http://tracking.example.org/browser/browser/base/content/test/general/benignPage.html";
|
||||
const TRACKING_PAGE = "http://tracking.example.org/browser/browser/base/content/test/general/trackingPage.html";
|
||||
var TrackingProtection = null;
|
||||
var tabbrowser = null;
|
||||
|
||||
var {UrlClassifierTestUtils} = ChromeUtils.import("resource://testing-common/UrlClassifierTestUtils.jsm", {});
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
TrackingProtection = tabbrowser = null;
|
||||
UrlClassifierTestUtils.cleanupTestTrackers();
|
|
@ -6,6 +6,9 @@
|
|||
* See also Bug 1178985.
|
||||
*/
|
||||
|
||||
const PREF = "privacy.trackingprotection.enabled";
|
||||
const PB_PREF = "privacy.trackingprotection.pbmode.enabled";
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
Services.prefs.clearUserPref(PREF);
|
||||
Services.prefs.clearUserPref(PB_PREF);
|
|
@ -4,9 +4,15 @@
|
|||
* See also Bug 1175858.
|
||||
*/
|
||||
|
||||
const PREF = "privacy.trackingprotection.enabled";
|
||||
const PB_PREF = "privacy.trackingprotection.pbmode.enabled";
|
||||
const BENIGN_PAGE = "http://tracking.example.org/browser/browser/base/content/test/general/benignPage.html";
|
||||
const TRACKING_PAGE = "http://tracking.example.org/browser/browser/base/content/test/general/trackingPage.html";
|
||||
var TrackingProtection = null;
|
||||
var tabbrowser = null;
|
||||
|
||||
var {UrlClassifierTestUtils} = ChromeUtils.import("resource://testing-common/UrlClassifierTestUtils.jsm", {});
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
TrackingProtection = tabbrowser = null;
|
||||
UrlClassifierTestUtils.cleanupTestTrackers();
|
|
@ -4,8 +4,11 @@
|
|||
// Test that sites added to the Tracking Protection whitelist in private
|
||||
// browsing mode don't persist once the private browsing window closes.
|
||||
|
||||
const PB_PREF = "privacy.trackingprotection.pbmode.enabled";
|
||||
const TRACKING_PAGE = "http://tracking.example.org/browser/browser/base/content/test/general/trackingPage.html";
|
||||
var TrackingProtection = null;
|
||||
var browser = null;
|
||||
var {UrlClassifierTestUtils} = ChromeUtils.import("resource://testing-common/UrlClassifierTestUtils.jsm", {});
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
TrackingProtection = browser = null;
|
||||
|
@ -75,7 +78,7 @@ add_task(async function testExceptionAddition() {
|
|||
let tab = await BrowserTestUtils.openNewForegroundTab({ gBrowser: browser, waitForLoad: true, waitForStateStop: true });
|
||||
|
||||
TrackingProtection = browser.ownerGlobal.TrackingProtection;
|
||||
await SpecialPowers.pushPrefEnv({"set": [[PB_PREF, true]]});
|
||||
await pushPrefs([PB_PREF, true]);
|
||||
|
||||
ok(TrackingProtection.enabled, "TP is enabled after setting the pref");
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
const URL = getRootDirectory(gTestPath).replace("chrome://mochitests/content", "http://mochi.test:8888") + "file_trackingUI_6.html";
|
||||
const URL = "http://mochi.test:8888/browser/browser/base/content/test/general/file_trackingUI_6.html";
|
||||
|
||||
function waitForSecurityChange(numChanges = 1) {
|
||||
return new Promise(resolve => {
|
|
@ -2,6 +2,11 @@
|
|||
* Test telemetry for Tracking Protection
|
||||
*/
|
||||
|
||||
const PREF = "privacy.trackingprotection.enabled";
|
||||
const BENIGN_PAGE = "http://tracking.example.org/browser/browser/base/content/test/general/benignPage.html";
|
||||
const TRACKING_PAGE = "http://tracking.example.org/browser/browser/base/content/test/general/trackingPage.html";
|
||||
const {UrlClassifierTestUtils} = ChromeUtils.import("resource://testing-common/UrlClassifierTestUtils.jsm", {});
|
||||
|
||||
/**
|
||||
* Enable local telemetry recording for the duration of the tests.
|
||||
*/
|
|
@ -8,7 +8,7 @@
|
|||
<p>Hello there!</p>
|
||||
<script type="application/javascript">
|
||||
function test_fetch() {
|
||||
let url = "http://trackertest.org/browser/browser/base/content/test/trackingUI/file_trackingUI_6.js";
|
||||
let url = "http://trackertest.org/browser/browser/base/content/test/general/file_trackingUI_6.js";
|
||||
return fetch(url);
|
||||
}
|
||||
</script>
|
|
@ -1,7 +0,0 @@
|
|||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
"extends": [
|
||||
"plugin:mozilla/browser-test"
|
||||
]
|
||||
};
|
|
@ -1,24 +0,0 @@
|
|||
[DEFAULT]
|
||||
tags = trackingprotection
|
||||
support-files =
|
||||
head.js
|
||||
trackingPage.html
|
||||
benignPage.html
|
||||
|
||||
[browser_trackingUI_1.js]
|
||||
[browser_trackingUI_2.js]
|
||||
[browser_trackingUI_3.js]
|
||||
[browser_trackingUI_4.js]
|
||||
[browser_trackingUI_5.js]
|
||||
[browser_trackingUI_6.js]
|
||||
support-files =
|
||||
file_trackingUI_6.html
|
||||
file_trackingUI_6.js
|
||||
file_trackingUI_6.js^headers^
|
||||
[browser_trackingUI_iframe.js]
|
||||
support-files =
|
||||
trackingPage_iframe.html
|
||||
[browser_trackingUI_telemetry.js]
|
||||
[browser_trackingUI_unloaded_documents.js]
|
||||
support-files =
|
||||
trackingPage_onunload.html
|
|
@ -1,29 +0,0 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
const URL = getRootDirectory(gTestPath).replace("chrome://mochitests/content", "http://example.org") + "trackingPage_iframe.html";
|
||||
|
||||
/**
|
||||
* Tests that sites that only contain trackers in iframes still
|
||||
* get the tracking protection UI.
|
||||
*/
|
||||
|
||||
add_task(async function test_iframe() {
|
||||
await UrlClassifierTestUtils.addTestTrackers();
|
||||
|
||||
await SpecialPowers.pushPrefEnv({ set: [[PREF, true]] });
|
||||
|
||||
await BrowserTestUtils.withNewTab(URL, async function(browser) {
|
||||
var TrackingProtection = browser.ownerGlobal.TrackingProtection;
|
||||
ok(TrackingProtection, "got TP object");
|
||||
ok(TrackingProtection.enabled, "TP is enabled");
|
||||
|
||||
is(TrackingProtection.content.getAttribute("state"), "blocked-tracking-content",
|
||||
'content: state="blocked-tracking-content"');
|
||||
is(TrackingProtection.icon.getAttribute("state"), "blocked-tracking-content",
|
||||
'icon: state="blocked-tracking-content"');
|
||||
is(TrackingProtection.icon.getAttribute("tooltiptext"),
|
||||
gNavigatorBundle.getString("trackingProtection.icon.activeTooltip"), "correct tooltip");
|
||||
});
|
||||
|
||||
UrlClassifierTestUtils.cleanupTestTrackers();
|
||||
});
|
|
@ -1,33 +0,0 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
const URL = getRootDirectory(gTestPath).replace("chrome://mochitests/content", "http://example.org") + "trackingPage_onunload.html";
|
||||
|
||||
/**
|
||||
* Tests that visiting a new page while a request to a tracker is still
|
||||
* in flight (such as when it was triggered on unload) does not cause
|
||||
* the tracking UI to appear.
|
||||
*/
|
||||
|
||||
add_task(async function test_onunload() {
|
||||
await UrlClassifierTestUtils.addTestTrackers();
|
||||
|
||||
await SpecialPowers.pushPrefEnv({ set: [[PREF, true]] });
|
||||
|
||||
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, URL);
|
||||
let browser = tab.linkedBrowser;
|
||||
|
||||
let loaded = BrowserTestUtils.browserLoaded(browser, false, "http://example.com/");
|
||||
await BrowserTestUtils.loadURI(browser, "http://example.com/");
|
||||
await loaded;
|
||||
var TrackingProtection = browser.ownerGlobal.TrackingProtection;
|
||||
ok(TrackingProtection, "got TP object");
|
||||
ok(TrackingProtection.enabled, "TP is enabled");
|
||||
|
||||
ok(!TrackingProtection.container.hidden, "The container is visible");
|
||||
ok(!TrackingProtection.content.hasAttribute("state"), "content: no state");
|
||||
ok(!TrackingProtection.icon.hasAttribute("state"), "icon: no state");
|
||||
ok(!TrackingProtection.icon.hasAttribute("tooltiptext"), "icon: no tooltip");
|
||||
|
||||
BrowserTestUtils.removeTab(tab);
|
||||
UrlClassifierTestUtils.cleanupTestTrackers();
|
||||
});
|
|
@ -1,77 +0,0 @@
|
|||
var {UrlClassifierTestUtils} = ChromeUtils.import("resource://testing-common/UrlClassifierTestUtils.jsm", {});
|
||||
|
||||
const PREF = "privacy.trackingprotection.enabled";
|
||||
const PB_PREF = "privacy.trackingprotection.pbmode.enabled";
|
||||
const ROOT = getRootDirectory(gTestPath).replace("chrome://mochitests/content", "http://tracking.example.org");
|
||||
const BENIGN_PAGE = ROOT + "benignPage.html";
|
||||
const TRACKING_PAGE = ROOT + "trackingPage.html";
|
||||
|
||||
function promiseWindowWillBeClosed(win) {
|
||||
return new Promise((resolve, reject) => {
|
||||
Services.obs.addObserver(function observe(subject, topic) {
|
||||
if (subject == win) {
|
||||
Services.obs.removeObserver(observe, topic);
|
||||
executeSoon(resolve);
|
||||
}
|
||||
}, "domwindowclosed");
|
||||
});
|
||||
}
|
||||
|
||||
function promiseWindowClosed(win) {
|
||||
let promise = promiseWindowWillBeClosed(win);
|
||||
win.close();
|
||||
return promise;
|
||||
}
|
||||
|
||||
function promiseOpenAndLoadWindow(aOptions, aWaitForDelayedStartup = false) {
|
||||
return new Promise(resolve => {
|
||||
let win = OpenBrowserWindow(aOptions);
|
||||
if (aWaitForDelayedStartup) {
|
||||
Services.obs.addObserver(function onDS(aSubject, aTopic, aData) {
|
||||
if (aSubject != win) {
|
||||
return;
|
||||
}
|
||||
Services.obs.removeObserver(onDS, "browser-delayed-startup-finished");
|
||||
resolve(win);
|
||||
}, "browser-delayed-startup-finished");
|
||||
|
||||
} else {
|
||||
win.addEventListener("load", function() {
|
||||
resolve(win);
|
||||
}, {once: true});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Waits for a load (or custom) event to finish in a given tab. If provided
|
||||
* load an uri into the tab.
|
||||
*
|
||||
* @param tab
|
||||
* The tab to load into.
|
||||
* @param [optional] url
|
||||
* The url to load, or the current url.
|
||||
* @return {Promise} resolved when the event is handled.
|
||||
* @resolves to the received event
|
||||
* @rejects if a valid load event is not received within a meaningful interval
|
||||
*/
|
||||
function promiseTabLoadEvent(tab, url) {
|
||||
info("Wait tab event: load");
|
||||
|
||||
function handle(loadedUrl) {
|
||||
if (loadedUrl === "about:blank" || (url && loadedUrl !== url)) {
|
||||
info(`Skipping spurious load event for ${loadedUrl}`);
|
||||
return false;
|
||||
}
|
||||
|
||||
info("Tab event received: load");
|
||||
return true;
|
||||
}
|
||||
|
||||
let loaded = BrowserTestUtils.browserLoaded(tab.linkedBrowser, false, handle);
|
||||
|
||||
if (url)
|
||||
BrowserTestUtils.loadURI(tab.linkedBrowser, url);
|
||||
|
||||
return loaded;
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<!-- Any copyright is dedicated to the Public Domain.
|
||||
- http://creativecommons.org/publicdomain/zero/1.0/ -->
|
||||
<html dir="ltr" xml:lang="en-US" lang="en-US">
|
||||
<head>
|
||||
<meta charset="utf8">
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="http://example.com/browser/browser/base/content/test/trackingUI/trackingPage.html"></iframe>
|
||||
</body>
|
||||
</html>
|
|
@ -1,18 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<!-- Any copyright is dedicated to the Public Domain.
|
||||
- http://creativecommons.org/publicdomain/zero/1.0/ -->
|
||||
<html dir="ltr" xml:lang="en-US" lang="en-US">
|
||||
<head>
|
||||
<meta charset="utf8">
|
||||
<script>
|
||||
window.onunload = function() {
|
||||
var img = new Image();
|
||||
img.src = "http://tracking.example.com/";
|
||||
document.body.appendChild(img);
|
||||
};
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
Testing tracking requests onunload.
|
||||
</body>
|
||||
</html>
|
|
@ -53,7 +53,6 @@ BROWSER_CHROME_MANIFESTS += [
|
|||
'content/test/tabPrompts/browser.ini',
|
||||
'content/test/tabs/browser.ini',
|
||||
'content/test/touch/browser.ini',
|
||||
'content/test/trackingUI/browser.ini',
|
||||
'content/test/urlbar/browser.ini',
|
||||
'content/test/webextensions/browser.ini',
|
||||
'content/test/webrtc/browser.ini',
|
||||
|
|
|
@ -17,8 +17,8 @@ skip-if = true # Bug 1113038 - Intermittent "Popup was opened"
|
|||
skip-if = os == "linux" # Intermittent NS_ERROR_NOT_AVAILABLE [nsIUrlClassifierDBService.beginUpdate]
|
||||
tag = trackingprotection
|
||||
support-files =
|
||||
!/browser/base/content/test/trackingUI/benignPage.html
|
||||
!/browser/base/content/test/trackingUI/trackingPage.html
|
||||
!/browser/base/content/test/general/benignPage.html
|
||||
!/browser/base/content/test/general/trackingPage.html
|
||||
[browser_trackingProtection_tour.js]
|
||||
tag = trackingprotection
|
||||
[browser_showMenu.js]
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
const PREF_INTRO_COUNT = "privacy.trackingprotection.introCount";
|
||||
const PREF_TP_ENABLED = "privacy.trackingprotection.enabled";
|
||||
const BENIGN_PAGE = "http://tracking.example.org/browser/browser/base/content/test/trackingUI/benignPage.html";
|
||||
const TRACKING_PAGE = "http://tracking.example.org/browser/browser/base/content/test/trackingUI/trackingPage.html";
|
||||
const BENIGN_PAGE = "http://tracking.example.org/browser/browser/base/content/test/general/benignPage.html";
|
||||
const TRACKING_PAGE = "http://tracking.example.org/browser/browser/base/content/test/general/trackingPage.html";
|
||||
const TOOLTIP_PANEL = document.getElementById("UITourTooltip");
|
||||
const TOOLTIP_ANCHOR = document.getElementById("tracking-protection-icon");
|
||||
|
||||
|
|
|
@ -802,25 +802,6 @@ nsChannelClassifier::SameLoadingURI(nsIDocument *aDoc, nsIChannel *aChannel)
|
|||
return NS_SUCCEEDED(rv) && equals;
|
||||
}
|
||||
|
||||
// static
|
||||
nsPIDOMWindowOuter*
|
||||
nsChannelClassifier::GetWindowForChannel(nsIChannel *aChannel)
|
||||
{
|
||||
nsCOMPtr<nsILoadContext> ctx;
|
||||
NS_QueryNotificationCallbacks(aChannel, ctx);
|
||||
if (!ctx) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<mozIDOMWindowProxy> window;
|
||||
ctx->GetAssociatedWindow(getter_AddRefs(window));
|
||||
if (!window) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return nsPIDOMWindowOuter::From(window);
|
||||
}
|
||||
|
||||
// static
|
||||
nsresult
|
||||
nsChannelClassifier::SetBlockedContent(nsIChannel *channel,
|
||||
|
@ -849,59 +830,41 @@ nsChannelClassifier::SetBlockedContent(nsIChannel *channel,
|
|||
classifiedChannel->SetMatchedInfo(aList, aProvider, aFullHash);
|
||||
}
|
||||
|
||||
nsCOMPtr<mozIDOMWindowProxy> win;
|
||||
nsCOMPtr<mozIThirdPartyUtil> thirdPartyUtil =
|
||||
do_GetService(THIRDPARTYUTIL_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, NS_OK);
|
||||
rv = thirdPartyUtil->GetTopWindowForChannel(channel, getter_AddRefs(win));
|
||||
NS_ENSURE_SUCCESS(rv, NS_OK);
|
||||
auto* pwin = nsPIDOMWindowOuter::From(win);
|
||||
nsCOMPtr<nsIDocShell> docShell = pwin->GetDocShell();
|
||||
if (!docShell) {
|
||||
return NS_OK;
|
||||
}
|
||||
nsCOMPtr<nsIDocument> doc = docShell->GetDocument();
|
||||
NS_ENSURE_TRUE(doc, NS_OK);
|
||||
|
||||
// This event might come after the user has navigated to another page.
|
||||
// To prevent showing the TrackingProtection UI on the wrong page, we need to
|
||||
// check that the loading URI for the channel is the same as the URI currently
|
||||
// loaded in the document that is associated with the channel (which may be
|
||||
// different than the top-level document, so we avoid ignoring all iframes).
|
||||
nsCOMPtr<nsPIDOMWindowOuter> win = GetWindowForChannel(channel);
|
||||
if (!win) {
|
||||
return NS_OK;
|
||||
}
|
||||
nsCOMPtr<nsIDocument> frameDoc = win->GetExtantDoc();
|
||||
|
||||
// If the blocked request is the document load request to an iframe that
|
||||
// contains a tracking page, the window associated with the channel belongs
|
||||
// to that iframe, not its loading parent. In this case we actually want to
|
||||
// compare load URIs with the parent frame, so we step up one level.
|
||||
bool isDocumentLoad = false;
|
||||
Unused << NS_WARN_IF(NS_FAILED(channel->GetIsDocument(&isDocumentLoad)));
|
||||
if (isDocumentLoad || !frameDoc) {
|
||||
win = win->GetParent();
|
||||
if (NS_WARN_IF(!win)) {
|
||||
return NS_OK;
|
||||
}
|
||||
frameDoc = win->GetExtantDoc();
|
||||
}
|
||||
|
||||
if (!frameDoc || !SameLoadingURI(frameDoc, channel)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Get the root docshell for updating the security UI.
|
||||
nsCOMPtr<nsPIDOMWindowOuter> topWin = win->GetScriptableTop();
|
||||
nsCOMPtr<nsIDocShell> topDocShell = topWin->GetDocShell();
|
||||
if (!topDocShell) {
|
||||
// loaded in the document.
|
||||
if (!SameLoadingURI(doc, channel)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Notify nsIWebProgressListeners of this security event.
|
||||
// Can be used to change the UI state.
|
||||
nsCOMPtr<nsISecurityEventSink> eventSink = do_QueryInterface(topDocShell, &rv);
|
||||
nsCOMPtr<nsISecurityEventSink> eventSink = do_QueryInterface(docShell, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, NS_OK);
|
||||
uint32_t state = 0;
|
||||
nsCOMPtr<nsISecureBrowserUI> securityUI;
|
||||
topDocShell->GetSecurityUI(getter_AddRefs(securityUI));
|
||||
docShell->GetSecurityUI(getter_AddRefs(securityUI));
|
||||
if (!securityUI) {
|
||||
return NS_OK;
|
||||
}
|
||||
securityUI->GetState(&state);
|
||||
if (aErrorCode == NS_ERROR_TRACKING_URI) {
|
||||
nsCOMPtr<nsIDocument> topLevelDoc = topDocShell->GetDocument();
|
||||
if (!topLevelDoc) {
|
||||
return NS_OK;
|
||||
}
|
||||
topLevelDoc->SetHasTrackingContentBlocked(true);
|
||||
doc->SetHasTrackingContentBlocked(true);
|
||||
state |= nsIWebProgressListener::STATE_BLOCKED_TRACKING_CONTENT;
|
||||
} else {
|
||||
state |= nsIWebProgressListener::STATE_BLOCKED_UNSAFE_CONTENT;
|
||||
|
@ -922,7 +885,7 @@ nsChannelClassifier::SetBlockedContent(nsIChannel *channel,
|
|||
|
||||
nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
|
||||
category,
|
||||
frameDoc,
|
||||
doc,
|
||||
nsContentUtils::eNECKO_PROPERTIES,
|
||||
message,
|
||||
params, ArrayLength(params));
|
||||
|
|
|
@ -80,8 +80,6 @@ private:
|
|||
bool IsHostnameWhitelisted(nsIURI *aUri, const nsACString &aWhitelisted);
|
||||
// Checks that the channel was loaded by the URI currently loaded in aDoc
|
||||
static bool SameLoadingURI(nsIDocument *aDoc, nsIChannel *aChannel);
|
||||
// Helper function to get the (not necessarily top-level) window from a channel.
|
||||
static nsPIDOMWindowOuter* GetWindowForChannel(nsIChannel *aChannel);
|
||||
// Note this function will be also used to decide whether or not to enable
|
||||
// channel annotation. When |aAnnotationsOnly| is true, this function
|
||||
// is called by ShouldEnableTrackingAnnotation(). Otherwise, this is called
|
||||
|
|
|
@ -44,5 +44,4 @@ skip-if = (os == 'linux' && debug) #Bug 1199778
|
|||
[test_classify_track.html]
|
||||
[test_gethash.html]
|
||||
[test_bug1254766.html]
|
||||
skip-if = os == "android" # Bug 1458635
|
||||
[test_cachemiss.html]
|
||||
|
|
Загрузка…
Ссылка в новой задаче