Bug 1548375 - Remove redundant canvas log info. r=baku
authorJ. Ryan Stinnett <jryans@gmail.com>
Wed, 01 May 2019 21:54:43 +0000
changeset 472246 69fb960771d254fde9b7567fd3f527a205a60555
parent 472245 1376a67f22b4d4d28c712bd74217644fbd5fb040
child 472247 9ea9cc51a20217f8883546904e1e56ac8b2391a0
push id112987
push usercbrindusan@mozilla.com
push dateThu, 02 May 2019 15:35:11 +0000
treeherdermozilla-inbound@56a1e86bccf1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1548375
milestone68.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
Bug 1548375 - Remove redundant canvas log info. r=baku Now that we're reporting to the page console, there's no need to include the top document URI, since that's obvious from the tab. In addition, the script file and line are already added by the console reporting path (and displayed with nicer formatting), so we don't need to add them to the message text. Differential Revision: https://phabricator.services.mozilla.com/D29573
dom/canvas/CanvasUtils.cpp
--- a/dom/canvas/CanvasUtils.cpp
+++ b/dom/canvas/CanvasUtils.cpp
@@ -76,27 +76,21 @@ bool IsImageExtractionAllowed(Document* 
   docURI->GetSpec(docURISpec);
 
   // Allow local files to extract canvas data.
   bool isFileURL;
   if (NS_SUCCEEDED(docURI->SchemeIs("file", &isFileURL)) && isFileURL) {
     return true;
   }
 
-  // Get calling script file and line for logging.
+  // Don't show canvas prompt for PDF.js
   JS::AutoFilename scriptFile;
-  unsigned scriptLine = 0;
-  bool isScriptKnown = false;
-  if (JS::DescribeScriptedCaller(aCx, &scriptFile, &scriptLine)) {
-    isScriptKnown = true;
-    // Don't show canvas prompt for PDF.js
-    if (scriptFile.get() &&
-        strcmp(scriptFile.get(), "resource://pdf.js/build/pdf.js") == 0) {
-      return true;
-    }
+  if (JS::DescribeScriptedCaller(aCx, &scriptFile) && scriptFile.get() &&
+      strcmp(scriptFile.get(), "resource://pdf.js/build/pdf.js") == 0) {
+    return true;
   }
 
   Document* topLevelDocument = aDocument->GetTopLevelContentDocument();
   nsIURI* topLevelDocURI =
       topLevelDocument ? topLevelDocument->GetDocumentURI() : nullptr;
   nsCString topLevelDocURISpec;
   if (topLevelDocURI) {
     topLevelDocURI->GetSpec(topLevelDocURISpec);
@@ -109,22 +103,18 @@ bool IsImageExtractionAllowed(Document* 
   NS_ENSURE_SUCCESS(rv, false);
 
   // Block all third-party attempts to extract canvas.
   bool isThirdParty = true;
   rv = thirdPartyUtil->IsThirdPartyURI(topLevelDocURI, docURI, &isThirdParty);
   NS_ENSURE_SUCCESS(rv, false);
   if (isThirdParty) {
     nsAutoString message;
-    message.AppendPrintf(
-        "Blocked third party %s in page %s from extracting canvas data.",
-        docURISpec.get(), topLevelDocURISpec.get());
-    if (isScriptKnown) {
-      message.AppendPrintf(" %s:%u.", scriptFile.get(), scriptLine);
-    }
+    message.AppendPrintf("Blocked third party %s from extracting canvas data.",
+                         docURISpec.get());
     nsContentUtils::ReportToConsoleNonLocalized(
         message, nsIScriptError::warningFlag, NS_LITERAL_CSTRING("Security"),
         aDocument);
     return false;
   }
 
   // Load Permission Manager service.
   nsCOMPtr<nsIPermissionManager> permissionManager =
@@ -153,35 +143,28 @@ bool IsImageExtractionAllowed(Document* 
   bool isAutoBlockCanvas =
       StaticPrefs::
           privacy_resistFingerprinting_autoDeclineNoUserInputCanvasPrompts() &&
       !EventStateManager::IsHandlingUserInput();
 
   if (isAutoBlockCanvas) {
     nsAutoString message;
     message.AppendPrintf(
-        "Blocked %s in page %s from extracting canvas data because no user "
-        "input was detected.",
-        docURISpec.get(), topLevelDocURISpec.get());
-    if (isScriptKnown) {
-      message.AppendPrintf(" %s:%u.", scriptFile.get(), scriptLine);
-    }
+        "Blocked %s from extracting canvas data because no user input was "
+        "detected.",
+        docURISpec.get());
     nsContentUtils::ReportToConsoleNonLocalized(
         message, nsIScriptError::warningFlag, NS_LITERAL_CSTRING("Security"),
         aDocument);
   } else {
     // It was in response to user input, so log and display the prompt.
     nsAutoString message;
     message.AppendPrintf(
-        "Blocked %s in page %s from extracting canvas data, but prompting the "
-        "user.",
-        docURISpec.get(), topLevelDocURISpec.get());
-    if (isScriptKnown) {
-      message.AppendPrintf(" %s:%u.", scriptFile.get(), scriptLine);
-    }
+        "Blocked %s from extracting canvas data, but prompting the user.",
+        docURISpec.get());
     nsContentUtils::ReportToConsoleNonLocalized(
         message, nsIScriptError::warningFlag, NS_LITERAL_CSTRING("Security"),
         aDocument);
   }
 
   // Prompt the user (asynchronous).
   nsPIDOMWindowOuter* win = aDocument->GetWindow();
   if (XRE_IsContentProcess()) {