зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1575335
- Avoid creating an extra copy of the file name URI when checking whether the currently running script is from a tracker; r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D42706 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
e5baa47643
Коммит
a9f1a2a5c2
|
@ -3573,8 +3573,14 @@ void Document::NoteScriptTrackingStatus(const nsACString& aURL,
|
|||
}
|
||||
}
|
||||
|
||||
bool Document::IsScriptTracking(const nsACString& aURL) const {
|
||||
return mTrackingScripts.Contains(aURL);
|
||||
bool Document::IsScriptTracking(JSContext* aCx) const {
|
||||
JS::AutoFilename filename;
|
||||
uint32_t line = 0;
|
||||
uint32_t column = 0;
|
||||
if (!JS::DescribeScriptedCaller(aCx, &filename, &line, &column)) {
|
||||
return false;
|
||||
}
|
||||
return mTrackingScripts.Contains(nsDependentCString(filename.get()));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -3904,11 +3904,13 @@ class Document : public nsINode,
|
|||
virtual AbstractThread* AbstractMainThreadFor(
|
||||
TaskCategory aCategory) override;
|
||||
|
||||
// The URLs passed to these functions should match what
|
||||
// JS::DescribeScriptedCaller() returns, since these APIs are used to
|
||||
// The URLs passed to this function should match what
|
||||
// JS::DescribeScriptedCaller() returns, since this API is used to
|
||||
// determine whether some code is being called from a tracking script.
|
||||
void NoteScriptTrackingStatus(const nsACString& aURL, bool isTracking);
|
||||
bool IsScriptTracking(const nsACString& aURL) const;
|
||||
// The JSContext passed to this method represents the context that we want to
|
||||
// determine if it belongs to a tracker.
|
||||
bool IsScriptTracking(JSContext* aCx) const;
|
||||
|
||||
// For more information on Flash classification, see
|
||||
// toolkit/components/url-classifier/flash-block-lists.rst
|
||||
|
|
|
@ -479,10 +479,7 @@ already_AddRefed<Promise> FetchRequest(nsIGlobalObject* aGlobal,
|
|||
loadGroup = doc->GetDocumentLoadGroup();
|
||||
cookieSettings = doc->CookieSettings();
|
||||
|
||||
nsAutoCString fileNameString;
|
||||
if (nsJSUtils::GetCallingLocation(cx, fileNameString)) {
|
||||
isTrackingFetch = doc->IsScriptTracking(fileNameString);
|
||||
}
|
||||
isTrackingFetch = doc->IsScriptTracking(cx);
|
||||
} else {
|
||||
principal = aGlobal->PrincipalOrNull();
|
||||
if (NS_WARN_IF(!principal)) {
|
||||
|
|
|
@ -2426,12 +2426,8 @@ void XMLHttpRequestMainThread::MaybeLowerChannelPriority() {
|
|||
}
|
||||
|
||||
JSContext* cx = jsapi.cx();
|
||||
nsAutoCString fileNameString;
|
||||
if (!nsJSUtils::GetCallingLocation(cx, fileNameString)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!doc->IsScriptTracking(fileNameString)) {
|
||||
if (!doc->IsScriptTracking(cx)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче