Title: [137267] trunk
Revision
137267
Author
[email protected]
Date
2012-12-11 01:17:59 -0800 (Tue, 11 Dec 2012)

Log Message

Web Inspector: Evaluate private browsing mode's effect on console messages.
https://bugs.webkit.org/show_bug.cgi?id=104383

Reviewed by Pavel Feldman.

Source/WebCore:

Two sets of console messages are currently gated on private browsing
mode being inactive. This patch centralizes the private browsing checks
in order to apply them equally to all console messages, and changes the
granularity at which they act.

The current checks block the console messages entirely. This patch
blocks only notifications to ChromeClient and ensures that messages
won't be passed to printf where they might end up in system logs.
Notifications to InspectorInstrumentation seem safe; so far as I can
tell, there's no compelling reason to prevent console-based debugging
in private browsing mode. This patch excludes those calls from the
private browsing check.

Test: inspector/console/clients-ignored-in-privatebrowsing.html

* loader/cache/CachedResourceLoader.cpp:
(WebCore::CachedResourceLoader::printAccessDeniedMessage):
    Drop the private browsing check.
* page/Console.cpp:
(WebCore::Console::addMessage):
    Add private browsing checks to the two ::addMessage variants that
    do real work. Ensure that calls to printf and notifications to
    ChromeClients are gated on these checks, but always allow
    notifications to InspectorInstrumentation.
* page/DOMWindow.cpp:
(WebCore::DOMWindow::printErrorMessage):
    Drop the private browsing check.

LayoutTests:

* inspector/console/clients-ignored-in-privatebrowsing-expected.txt: Added.
* inspector/console/clients-ignored-in-privatebrowsing.html: Added.
* platform/chromium/TestExpectations:
    Skip this test on Chromium, as that port doesn't use PrivateBrowsing

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (137266 => 137267)


--- trunk/LayoutTests/ChangeLog	2012-12-11 09:15:43 UTC (rev 137266)
+++ trunk/LayoutTests/ChangeLog	2012-12-11 09:17:59 UTC (rev 137267)
@@ -1,3 +1,15 @@
+2012-12-11  Mike West  <[email protected]>
+
+        Web Inspector: Evaluate private browsing mode's effect on console messages.
+        https://bugs.webkit.org/show_bug.cgi?id=104383
+
+        Reviewed by Pavel Feldman.
+
+        * inspector/console/clients-ignored-in-privatebrowsing-expected.txt: Added.
+        * inspector/console/clients-ignored-in-privatebrowsing.html: Added.
+        * platform/chromium/TestExpectations:
+            Skip this test on Chromium, as that port doesn't use PrivateBrowsing
+
 2012-12-11  Andrey Kosyakov  <[email protected]>
 
         Web Inspector: better coverage for inspector/profiler/cpu-profiler-profiling-without-inspector.html

Added: trunk/LayoutTests/inspector/console/clients-ignored-in-privatebrowsing-expected.txt (0 => 137267)


--- trunk/LayoutTests/inspector/console/clients-ignored-in-privatebrowsing-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector/console/clients-ignored-in-privatebrowsing-expected.txt	2012-12-11 09:17:59 UTC (rev 137267)
@@ -0,0 +1,4 @@
+In PrivateBrowsing mode, console messages are visible in the Console, but aren't sent to ChromeClients (or printf'd) in order to ensure they never end up in logs. Better safe than sorry.
+
+log: This should show up once console messages are dumped, but should _not_ show up as a "CONSOLE MESSAGE:" at the top of the output.
+

Added: trunk/LayoutTests/inspector/console/clients-ignored-in-privatebrowsing.html (0 => 137267)


--- trunk/LayoutTests/inspector/console/clients-ignored-in-privatebrowsing.html	                        (rev 0)
+++ trunk/LayoutTests/inspector/console/clients-ignored-in-privatebrowsing.html	2012-12-11 09:17:59 UTC (rev 137267)
@@ -0,0 +1,30 @@
+<html>
+<head>
+<script src=""
+<script src=""
+<script>
+
+function test()
+{
+    if (window.testRunner)
+        testRunner.setPrivateBrowsingEnabled(true);
+
+    console.log('This should show up once console messages are dumped, but should _not_ show up as a "CONSOLE MESSAGE:" at the top of the output.');
+
+    InspectorTest.dumpConsoleMessages();
+
+    if (window.testRunner)
+        testRunner.setPrivateBrowsingEnabled(false);
+    InspectorTest.completeTest();
+}
+
+</script>
+</head>
+
+<body _onload_="runTest()">
+<p>In PrivateBrowsing mode, console messages are visible in the Console, but
+aren't sent to ChromeClients (or printf'd) in order to ensure they never end
+up in logs. Better safe than sorry.</p>
+
+</body>
+</html>

Modified: trunk/LayoutTests/platform/chromium/TestExpectations (137266 => 137267)


--- trunk/LayoutTests/platform/chromium/TestExpectations	2012-12-11 09:15:43 UTC (rev 137266)
+++ trunk/LayoutTests/platform/chromium/TestExpectations	2012-12-11 09:17:59 UTC (rev 137267)
@@ -643,6 +643,7 @@
 storage/domstorage/localstorage/private-browsing-affects-storage.html [ WontFix ]
 storage/domstorage/sessionstorage/private-browsing-affects-storage.html [ WontFix ]
 storage/websql/private-browsing-noread-nowrite.html [ WontFix ]
+inspector/console/clients-ignored-in-privatebrowsing.html [ WontFix ]
 
 # We don't let anyone set status in the browser.
 plugins/set-status.html [ WontFix ]

Modified: trunk/Source/WebCore/ChangeLog (137266 => 137267)


--- trunk/Source/WebCore/ChangeLog	2012-12-11 09:15:43 UTC (rev 137266)
+++ trunk/Source/WebCore/ChangeLog	2012-12-11 09:17:59 UTC (rev 137267)
@@ -1,3 +1,38 @@
+2012-12-11  Mike West  <[email protected]>
+
+        Web Inspector: Evaluate private browsing mode's effect on console messages.
+        https://bugs.webkit.org/show_bug.cgi?id=104383
+
+        Reviewed by Pavel Feldman.
+
+        Two sets of console messages are currently gated on private browsing
+        mode being inactive. This patch centralizes the private browsing checks
+        in order to apply them equally to all console messages, and changes the
+        granularity at which they act.
+
+        The current checks block the console messages entirely. This patch
+        blocks only notifications to ChromeClient and ensures that messages
+        won't be passed to printf where they might end up in system logs.
+        Notifications to InspectorInstrumentation seem safe; so far as I can
+        tell, there's no compelling reason to prevent console-based debugging
+        in private browsing mode. This patch excludes those calls from the
+        private browsing check.
+
+        Test: inspector/console/clients-ignored-in-privatebrowsing.html
+
+        * loader/cache/CachedResourceLoader.cpp:
+        (WebCore::CachedResourceLoader::printAccessDeniedMessage):
+            Drop the private browsing check.
+        * page/Console.cpp:
+        (WebCore::Console::addMessage):
+            Add private browsing checks to the two ::addMessage variants that
+            do real work. Ensure that calls to printf and notifications to
+            ChromeClients are gated on these checks, but always allow
+            notifications to InspectorInstrumentation.
+        * page/DOMWindow.cpp:
+        (WebCore::DOMWindow::printErrorMessage):
+            Drop the private browsing check.
+
 2012-12-10  Dan Winship  <[email protected]>
 
         [Soup] Fix spelling of "initiating" in API.

Modified: trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp (137266 => 137267)


--- trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp	2012-12-11 09:15:43 UTC (rev 137266)
+++ trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp	2012-12-11 09:17:59 UTC (rev 137267)
@@ -630,17 +630,12 @@
     if (!frame())
         return;
 
-    Settings* settings = frame()->settings();
-    if (!settings || settings->privateBrowsingEnabled())
-        return;
-
     String message;
     if (!m_document || m_document->url().isNull())
         message = "Unsafe attempt to load URL " + url.string() + '.';
     else
         message = "Unsafe attempt to load URL " + url.string() + " from frame with URL " + m_document->url().string() + ". Domains, protocols and ports must match.\n";
 
-    // FIXME: provide line number and source URL.
     frame()->document()->addConsoleMessage(OtherMessageSource, LogMessageType, ErrorMessageLevel, message);
 }
 

Modified: trunk/Source/WebCore/page/Console.cpp (137266 => 137267)


--- trunk/Source/WebCore/page/Console.cpp	2012-12-11 09:15:43 UTC (rev 137266)
+++ trunk/Source/WebCore/page/Console.cpp	2012-12-11 09:17:59 UTC (rev 137267)
@@ -47,6 +47,7 @@
 #include "ScriptProfiler.h"
 #include "ScriptValue.h"
 #include "ScriptableDocumentParser.h"
+#include "Settings.h"
 #include <stdio.h>
 #include <wtf/UnusedParam.h>
 #include <wtf/text/CString.h>
@@ -163,16 +164,19 @@
     if (!page)
         return;
 
-    page->chrome()->client()->addMessageToConsole(source, type, level, message, lineNumber, url);
-
     if (callStack)
         InspectorInstrumentation::addMessageToConsole(page, source, type, level, message, callStack, requestIdentifier);
     else
         InspectorInstrumentation::addMessageToConsole(page, source, type, level, message, url, lineNumber, state, requestIdentifier);
 
-    if (!Console::shouldPrintExceptions())
+    if (!m_frame->settings() || m_frame->settings()->privateBrowsingEnabled())
         return;
 
+    page->chrome()->client()->addMessageToConsole(source, type, level, message, lineNumber, url);
+
+    if (!shouldPrintExceptions())
+        return;
+
     printSourceURLAndLine(url, lineNumber);
     printMessageSourceAndLevelPrefix(source, level);
 
@@ -194,6 +198,16 @@
     RefPtr<ScriptCallStack> callStack(createScriptCallStack(state, stackSize));
     const ScriptCallFrame& lastCaller = callStack->at(0);
 
+    String message;
+    bool gotMessage = arguments->getFirstArgumentAsString(message);
+    InspectorInstrumentation::addMessageToConsole(page, ConsoleAPIMessageSource, type, level, message, state, arguments.release());
+
+    if (!m_frame->settings() || m_frame->settings()->privateBrowsingEnabled())
+        return;
+
+    if (gotMessage)
+        page->chrome()->client()->addMessageToConsole(ConsoleAPIMessageSource, type, level, message, lastCaller.lineNumber(), lastCaller.sourceURL());
+
     if (shouldPrintExceptions()) {
         printSourceURLAndLine(lastCaller.sourceURL(), 0);
         printMessageSourceAndLevelPrefix(ConsoleAPIMessageSource, level);
@@ -213,12 +227,6 @@
             printf("\t%s\n", functionName.utf8().data());
         }
     }
-
-    String message;
-    if (arguments->getFirstArgumentAsString(message))
-        page->chrome()->client()->addMessageToConsole(ConsoleAPIMessageSource, type, level, message, lastCaller.lineNumber(), lastCaller.sourceURL());
-
-    InspectorInstrumentation::addMessageToConsole(page, ConsoleAPIMessageSource, type, level, message, state, arguments.release());
 }
 
 void Console::debug(ScriptState* state, PassRefPtr<ScriptArguments> arguments)

Modified: trunk/Source/WebCore/page/DOMWindow.cpp (137266 => 137267)


--- trunk/Source/WebCore/page/DOMWindow.cpp	2012-12-11 09:15:43 UTC (rev 137266)
+++ trunk/Source/WebCore/page/DOMWindow.cpp	2012-12-11 09:17:59 UTC (rev 137267)
@@ -1756,12 +1756,6 @@
     if (message.isEmpty())
         return;
 
-    Settings* settings = m_frame->settings();
-    if (!settings)
-        return;
-    if (settings->privateBrowsingEnabled())
-        return;
-
     console()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, message);
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to