зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 2 changesets (bug 1474651) for lint failure in /builds/worker/checkouts/gecko/toolkit/components/antitracking/test/browser/popup.html:8:126 on a CLOSED TREE
Backed out changeset f05247b25d5e (bug 1474651) Backed out changeset acee48580902 (bug 1474651)
This commit is contained in:
Родитель
baae926f53
Коммит
c1bbe21ac6
|
@ -8838,26 +8838,6 @@ nsContentUtils::IsThirdPartyWindowOrChannel(nsPIDOMWindowInner* aWindow,
|
|||
return thirdParty;
|
||||
}
|
||||
|
||||
// static public
|
||||
bool
|
||||
nsContentUtils::IsTrackingResourceWindow(nsPIDOMWindowInner* aWindow)
|
||||
{
|
||||
MOZ_ASSERT(aWindow);
|
||||
|
||||
nsIDocument* document = aWindow->GetExtantDoc();
|
||||
if (!document) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel =
|
||||
do_QueryInterface(document->GetChannel());
|
||||
if (!httpChannel) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return httpChannel->GetIsTrackingResource();
|
||||
}
|
||||
|
||||
// static public
|
||||
bool
|
||||
nsContentUtils::StorageDisabledByAntiTracking(nsPIDOMWindowInner* aWindow,
|
||||
|
|
|
@ -2964,12 +2964,6 @@ public:
|
|||
nsIChannel* aChannel,
|
||||
nsIURI* aURI);
|
||||
|
||||
/*
|
||||
* Returns true if this window's channel has been marked as a tracking
|
||||
* resource.
|
||||
*/
|
||||
static bool IsTrackingResourceWindow(nsPIDOMWindowInner* aWindow);
|
||||
|
||||
/*
|
||||
* Serializes a HTML nsINode into its markup representation.
|
||||
*/
|
||||
|
|
|
@ -12453,10 +12453,9 @@ nsIDocument::MaybeAllowStorageForOpener()
|
|||
return;
|
||||
}
|
||||
|
||||
// No 3rd party or no tracking resource.
|
||||
// No 3rd party.
|
||||
if (!nsContentUtils::IsThirdPartyWindowOrChannel(openerInner, nullptr,
|
||||
nullptr) ||
|
||||
!nsContentUtils::IsTrackingResourceWindow(openerInner)) {
|
||||
nullptr)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -6897,14 +6897,12 @@ nsGlobalWindowOuter::OpenInternal(const nsAString& aUrl, const nsAString& aName,
|
|||
}
|
||||
}
|
||||
|
||||
bool windowExists = WindowExists(aName, forceNoOpener, !aCalledNoScript);
|
||||
|
||||
// XXXbz When this gets fixed to not use LegacyIsCallerNativeCode()
|
||||
// (indirectly) maybe we can nix the AutoJSAPI usage OnLinkClickEvent::Run.
|
||||
// But note that if you change this to GetEntryGlobal(), say, then
|
||||
// OnLinkClickEvent::Run will need a full-blown AutoEntryScript.
|
||||
const bool checkForPopup = !nsContentUtils::LegacyIsCallerChromeOrNativeCode() &&
|
||||
!aDialog && !windowExists;
|
||||
!aDialog && !WindowExists(aName, forceNoOpener, !aCalledNoScript);
|
||||
|
||||
// Note: the Void handling here is very important, because the window watcher
|
||||
// expects a null URL string (not an empty string) if there is no URL to load.
|
||||
|
@ -6912,8 +6910,6 @@ nsGlobalWindowOuter::OpenInternal(const nsAString& aUrl, const nsAString& aName,
|
|||
url.SetIsVoid(true);
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
|
||||
// It's important to do this security check before determining whether this
|
||||
// window opening should be blocked, to ensure that we don't FireAbuseEvents
|
||||
// for a window opening that wouldn't have succeeded in the first place.
|
||||
|
@ -6927,7 +6923,7 @@ nsGlobalWindowOuter::OpenInternal(const nsAString& aUrl, const nsAString& aName,
|
|||
// If we're not navigating, we assume that whoever *does* navigate the
|
||||
// window will do a security check of their own.
|
||||
if (!url.IsVoid() && !aDialog && aNavigate)
|
||||
rv = SecurityCheckURL(url.get(), getter_AddRefs(uri));
|
||||
rv = SecurityCheckURL(url.get());
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
|
@ -7029,10 +7025,6 @@ nsGlobalWindowOuter::OpenInternal(const nsAString& aUrl, const nsAString& aName,
|
|||
|
||||
// success!
|
||||
|
||||
if (!aCalledNoScript && !windowExists && uri) {
|
||||
MaybeAllowStorageForOpenedWindow(uri);
|
||||
}
|
||||
|
||||
NS_ENSURE_TRUE(domReturn, NS_OK);
|
||||
nsCOMPtr<nsPIDOMWindowOuter> outerReturn =
|
||||
nsPIDOMWindowOuter::From(domReturn);
|
||||
|
@ -7057,29 +7049,6 @@ nsGlobalWindowOuter::OpenInternal(const nsAString& aUrl, const nsAString& aName,
|
|||
return rv;
|
||||
}
|
||||
|
||||
void
|
||||
nsGlobalWindowOuter::MaybeAllowStorageForOpenedWindow(nsIURI* aURI)
|
||||
{
|
||||
nsGlobalWindowInner *inner = GetCurrentInnerWindowInternal();
|
||||
if (NS_WARN_IF(!inner)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// No 3rd party or no tracking resource.
|
||||
if (!nsContentUtils::IsThirdPartyWindowOrChannel(inner, nullptr, nullptr) ||
|
||||
!nsContentUtils::IsTrackingResourceWindow(inner)) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsAutoString origin;
|
||||
nsresult rv = nsContentUtils::GetUTFOrigin(aURI, origin);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return;
|
||||
}
|
||||
|
||||
inner->AddFirstPartyStorageAccessGrantedFor(origin, true);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
// nsGlobalWindowOuter: Helper Functions
|
||||
//*****************************************************************************
|
||||
|
@ -7139,7 +7108,7 @@ nsGlobalWindowOuter::GetScrollFrame()
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsGlobalWindowOuter::SecurityCheckURL(const char *aURL, nsIURI** aURI)
|
||||
nsGlobalWindowOuter::SecurityCheckURL(const char *aURL)
|
||||
{
|
||||
nsCOMPtr<nsPIDOMWindowInner> sourceWindow = do_QueryInterface(GetEntryGlobal());
|
||||
if (!sourceWindow) {
|
||||
|
@ -7172,7 +7141,6 @@ nsGlobalWindowOuter::SecurityCheckURL(const char *aURL, nsIURI** aURI)
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
uri.forget(aURI);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -906,7 +906,7 @@ public:
|
|||
already_AddRefed<nsIDocShellTreeOwner> GetTreeOwner();
|
||||
already_AddRefed<nsIBaseWindow> GetTreeOwnerWindow();
|
||||
already_AddRefed<nsIWebBrowserChrome> GetWebBrowserChrome();
|
||||
nsresult SecurityCheckURL(const char *aURL, nsIURI** aURI);
|
||||
nsresult SecurityCheckURL(const char *aURL);
|
||||
bool IsPrivateBrowsing();
|
||||
|
||||
bool PopupWhitelisted();
|
||||
|
@ -1053,8 +1053,6 @@ private:
|
|||
|
||||
nsresult GetInterfaceInternal(const nsIID& aIID, void** aSink);
|
||||
|
||||
void MaybeAllowStorageForOpenedWindow(nsIURI* aURI);
|
||||
|
||||
public:
|
||||
// Dispatch a runnable related to the global.
|
||||
virtual nsresult Dispatch(mozilla::TaskCategory aCategory,
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
<h1>hi!</h1>
|
||||
<script>
|
||||
|
||||
SpecialPowers.wrap(document).userInteractionForTesting();
|
||||
opener.postMessage("hello!", "*");
|
||||
window.close();
|
||||
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>A popup!</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>hi!</h1>
|
||||
<script>
|
||||
|
||||
SpecialPowers.wrap(document).userInteractionForTesting();
|
||||
window.close();
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Tracker</title>
|
||||
<title>Interact with me!</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Tracker</h1>
|
||||
<h1>Interact with me!</h1>
|
||||
<script>
|
||||
|
||||
function info(msg) {
|
||||
|
@ -19,9 +19,20 @@ function is(a, b, msg) {
|
|||
}
|
||||
|
||||
onmessage = function(e) {
|
||||
let runnableStr = `(() => {return (${e.data.callback});})();`;
|
||||
let runnableStr = `(() => {return (${e.data.blockingCallback});})();`;
|
||||
let runnable = eval(runnableStr); // eslint-disable-line no-eval
|
||||
runnable.call(this).then(_ => {
|
||||
info("Let's do a window.open()");
|
||||
return new Promise(resolve => {
|
||||
onmessage = resolve;
|
||||
window.open("3rdPartyOpen.html");
|
||||
});
|
||||
}).then(_ => {
|
||||
info("The popup has been dismissed!");
|
||||
let runnableStr = `(() => {return (${e.data.nonBlockingCallback});})();`;
|
||||
let runnable = eval(runnableStr); // eslint-disable-line no-eval
|
||||
return runnable.call(this);
|
||||
}).then(_ => {
|
||||
parent.postMessage({ type: "finish" }, "*");
|
||||
});
|
||||
};
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Interact with me!</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Interact with me!</h1>
|
||||
<script>
|
||||
|
||||
function info(msg) {
|
||||
parent.postMessage({ type: "info", msg }, "*");
|
||||
}
|
||||
|
||||
function ok(what, msg) {
|
||||
parent.postMessage({ type: "ok", what: !!what, msg }, "*");
|
||||
}
|
||||
|
||||
function is(a, b, msg) {
|
||||
ok(a === b, msg);
|
||||
}
|
||||
|
||||
onmessage = function(e) {
|
||||
let runnableStr = `(() => {return (${e.data.blockingCallback});})();`;
|
||||
let runnable = eval(runnableStr); // eslint-disable-line no-eval
|
||||
runnable.call(this).then(_ => {
|
||||
info("Let's do a window.open()");
|
||||
return new Promise(resolve => {
|
||||
onmessage = resolve;
|
||||
window.open("3rdPartyOpen.html");
|
||||
});
|
||||
}).then(_ => {
|
||||
info("The popup has been dismissed!");
|
||||
let runnableStr = `(() => {return (${e.data.nonBlockingCallback});})();`;
|
||||
let runnable = eval(runnableStr); // eslint-disable-line no-eval
|
||||
return runnable.call(this);
|
||||
}).then(_ => {
|
||||
parent.postMessage({ type: "finish" }, "*");
|
||||
});
|
||||
};
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -4,11 +4,8 @@ support-files =
|
|||
page.html
|
||||
3rdParty.html
|
||||
3rdPartyUI.html
|
||||
3rdPartyWO.html
|
||||
3rdPartyOpen.html
|
||||
3rdPartyOpenUI.html
|
||||
empty.js
|
||||
popup.html
|
||||
|
||||
[browser_blockingCookies.js]
|
||||
support-files = server.sjs
|
||||
|
|
|
@ -4,29 +4,20 @@ const TEST_3RD_PARTY_DOMAIN = "https://tracking.example.com/";
|
|||
const TEST_PATH = "browser/toolkit/components/antitracking/test/browser/";
|
||||
|
||||
const TEST_TOP_PAGE = TEST_DOMAIN + TEST_PATH + "page.html";
|
||||
const TEST_POPUP_PAGE = TEST_DOMAIN + TEST_PATH + "popup.html";
|
||||
const TEST_3RD_PARTY_PAGE = TEST_3RD_PARTY_DOMAIN + TEST_PATH + "3rdParty.html";
|
||||
const TEST_3RD_PARTY_PAGE_WO = TEST_3RD_PARTY_DOMAIN + TEST_PATH + "3rdPartyWO.html";
|
||||
const TEST_3RD_PARTY_PAGE_UI = TEST_3RD_PARTY_DOMAIN + TEST_PATH + "3rdPartyUI.html";
|
||||
|
||||
let {UrlClassifierTestUtils} = ChromeUtils.import("resource://testing-common/UrlClassifierTestUtils.jsm", {});
|
||||
|
||||
this.AntiTracking = {
|
||||
runTest(name, callbackTracking, callbackNonTracking, cleanupFunction, extraPrefs) {
|
||||
// Here we want to test that a 3rd party context is simply blocked.
|
||||
this._createTask(name, true, callbackTracking, extraPrefs);
|
||||
this._createCleanupTask(cleanupFunction);
|
||||
|
||||
if (callbackNonTracking) {
|
||||
// Here we want to test that a 3rd party context is not blocked if pref is off.
|
||||
this._createTask(name, false, callbackNonTracking);
|
||||
this._createCleanupTask(cleanupFunction);
|
||||
|
||||
// Permission granted when there is a window.open()
|
||||
this._createWindowOpenTask(name, callbackTracking, callbackNonTracking, extraPrefs);
|
||||
this._createCleanupTask(cleanupFunction);
|
||||
|
||||
// Permission granted when there is user-interaction.
|
||||
this._createUserInteractionTask(name, callbackTracking, callbackNonTracking, extraPrefs);
|
||||
this._createCleanupTask(cleanupFunction);
|
||||
}
|
||||
|
@ -114,9 +105,9 @@ this.AntiTracking = {
|
|||
});
|
||||
},
|
||||
|
||||
_createWindowOpenTask(name, blockingCallback, nonBlockingCallback, extraPrefs) {
|
||||
_createUserInteractionTask(name, blockingCallback, nonBlockingCallback, extraPrefs) {
|
||||
add_task(async function() {
|
||||
info("Starting window-open test " + name);
|
||||
info("Starting user-interaction test " + name);
|
||||
await AntiTracking._setupTest(true, extraPrefs);
|
||||
|
||||
info("Creating a new tab");
|
||||
|
@ -128,7 +119,7 @@ this.AntiTracking = {
|
|||
|
||||
info("Creating a 3rd party content");
|
||||
await ContentTask.spawn(browser,
|
||||
{ page: TEST_3RD_PARTY_PAGE_WO,
|
||||
{ page: TEST_3RD_PARTY_PAGE_UI,
|
||||
blockingCallback: blockingCallback.toString(),
|
||||
nonBlockingCallback: nonBlockingCallback.toString(),
|
||||
},
|
||||
|
@ -168,103 +159,6 @@ this.AntiTracking = {
|
|||
info("Removing the tab");
|
||||
BrowserTestUtils.removeTab(tab);
|
||||
|
||||
UrlClassifierTestUtils.cleanupTestTrackers();
|
||||
});
|
||||
},
|
||||
|
||||
_createUserInteractionTask(name, blockingCallback, nonBlockingCallback, extraPrefs) {
|
||||
add_task(async function() {
|
||||
info("Starting user-interaction test " + name);
|
||||
await AntiTracking._setupTest(true, extraPrefs);
|
||||
|
||||
info("Creating a new tab");
|
||||
let tab = BrowserTestUtils.addTab(gBrowser, TEST_TOP_PAGE);
|
||||
gBrowser.selectedTab = tab;
|
||||
|
||||
let browser = gBrowser.getBrowserForTab(tab);
|
||||
await BrowserTestUtils.browserLoaded(browser);
|
||||
|
||||
info("Creating a 3rd party content");
|
||||
await ContentTask.spawn(browser,
|
||||
{ page: TEST_3RD_PARTY_PAGE_UI,
|
||||
popup: TEST_POPUP_PAGE,
|
||||
blockingCallback: blockingCallback.toString(),
|
||||
nonBlockingCallback: nonBlockingCallback.toString(),
|
||||
},
|
||||
async function(obj) {
|
||||
let ifr = content.document.createElement("iframe");
|
||||
let loading = new content.Promise(resolve => { ifr.onload = resolve; });
|
||||
content.document.body.appendChild(ifr);
|
||||
ifr.src = obj.page;
|
||||
await loading;
|
||||
|
||||
info("The 3rd party content should not have access to first party storage.");
|
||||
await new content.Promise(resolve => {
|
||||
content.addEventListener("message", function msg(event) {
|
||||
if (event.data.type == "finish") {
|
||||
content.removeEventListener("message", msg);
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.data.type == "ok") {
|
||||
ok(event.data.what, event.data.msg);
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.data.type == "info") {
|
||||
info(event.data.msg);
|
||||
return;
|
||||
}
|
||||
|
||||
ok(false, "Unknown message");
|
||||
});
|
||||
ifr.contentWindow.postMessage({ callback: obj.blockingCallback }, "*");
|
||||
});
|
||||
|
||||
let windowClosed = new content.Promise(resolve => {
|
||||
Services.ww.registerNotification(function notification(aSubject, aTopic, aData) {
|
||||
if (aTopic == "domwindowclosed") {
|
||||
Services.ww.unregisterNotification(notification);
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
info("Opening a window from the iframe.");
|
||||
ifr.contentWindow.open(obj.popup);
|
||||
|
||||
info("Let's wait for the window to be closed");
|
||||
await windowClosed;
|
||||
|
||||
info("The 3rd party content should have access to first party storage.");
|
||||
await new content.Promise(resolve => {
|
||||
content.addEventListener("message", function msg(event) {
|
||||
if (event.data.type == "finish") {
|
||||
content.removeEventListener("message", msg);
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.data.type == "ok") {
|
||||
ok(event.data.what, event.data.msg);
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.data.type == "info") {
|
||||
info(event.data.msg);
|
||||
return;
|
||||
}
|
||||
|
||||
ok(false, "Unknown message");
|
||||
});
|
||||
ifr.contentWindow.postMessage({ callback: obj.nonBlockingCallback }, "*");
|
||||
});
|
||||
});
|
||||
|
||||
info("Removing the tab");
|
||||
BrowserTestUtils.removeTab(tab);
|
||||
|
||||
UrlClassifierTestUtils.cleanupTestTrackers();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Just a popup that does a redirect</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Just a popup that does a redirect</h1>
|
||||
<script>
|
||||
window.location = "https://tracking.example.com/browser/toolkit/components/antitracking/test/browser/3rdPartyOpenUI.html"
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче