https://bugs.webkit.org/show_bug.cgi?id=85009
Source/WebCore:
Delete console message arguments when DOMWindow where the messages were created
is reset on its frame.
Reviewed by Pavel Feldman.
Test: http/tests/inspector-enabled/console-clear-arguments-on-frame-navigation.html
* inspector/ConsoleMessage.cpp:
(WebCore::ConsoleMessage::addToFrontend):
(WebCore::ConsoleMessage::windowCleared):
(WebCore::ConsoleMessage::argumentCount):
(WebCore):
* inspector/ConsoleMessage.h:
(ConsoleMessage):
* inspector/InspectorConsoleAgent.cpp:
(WebCore::InspectorConsoleAgent::consoleMessageArgumentCounts):
(WebCore):
* inspector/InspectorConsoleAgent.h:
(InspectorConsoleAgent):
* page/Frame.cpp:
(WebCore::Frame::clearDOMWindow):
(WebCore::Frame::setDOMWindow):
* testing/Internals.cpp:
(WebCore):
(WebCore::Internals::consoleMessageArgumentCounts):
* testing/Internals.h:
(Internals):
* testing/Internals.idl:
LayoutTests:
Test that after frame navigation all arguments passed to the console messages
created in that frame will be discarded and not prevent the frame context from
being GC'ed.
Reviewed by Pavel Feldman.
* http/tests/inspector-enabled/console-clear-arguments-on-frame-navigation-expected.txt: Added.
* http/tests/inspector-enabled/console-clear-arguments-on-frame-navigation.html: Added.
* http/tests/inspector-enabled/console-clear-arguments-on-frame-remove-expected.txt:
* http/tests/inspector-enabled/console-clear-arguments-on-frame-remove.html:
* http/tests/inspector-enabled/resources/console-clear-arguments-test.js: Added.
(print):
(dumpConsoleMessageArgumentCounts):
* http/tests/inspector/console-test.js:
(initialize_ConsoleTest.InspectorTest.checkConsoleMessagesDontHaveParameters):
(initialize_ConsoleTest):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@115553
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2012-04-27 Yury Semikhatsky <yurys@chromium.org>
+
+ ScriptStateProtectedPtr should not keep a strong reference to the context
+ https://bugs.webkit.org/show_bug.cgi?id=85009
+
+ Test that after frame navigation all arguments passed to the console messages
+ created in that frame will be discarded and not prevent the frame context from
+ being GC'ed.
+
+ Reviewed by Pavel Feldman.
+
+ * http/tests/inspector-enabled/console-clear-arguments-on-frame-navigation-expected.txt: Added.
+ * http/tests/inspector-enabled/console-clear-arguments-on-frame-navigation.html: Added.
+ * http/tests/inspector-enabled/console-clear-arguments-on-frame-remove-expected.txt:
+ * http/tests/inspector-enabled/console-clear-arguments-on-frame-remove.html:
+ * http/tests/inspector-enabled/resources/console-clear-arguments-test.js: Added.
+ (print):
+ (dumpConsoleMessageArgumentCounts):
+ * http/tests/inspector/console-test.js:
+ (initialize_ConsoleTest.InspectorTest.checkConsoleMessagesDontHaveParameters):
+ (initialize_ConsoleTest):
+
2012-04-28 Csaba Osztrogonác <ossy@webkit.org>
[Qt] Unreviewed weekend gardening, skip new failing tests.
--- /dev/null
+CONSOLE MESSAGE: line 2: A message with first argument string
+CONSOLE MESSAGE: line 3: 2011
+CONSOLE MESSAGE: line 4: [object Window]
+Tests that Web Inspector will discard console message arguments when iframe where the message was logged is navigated to a different page.
+
+
+PASSED: found argument counts for 3 messages
+PASSED: message #0 has no arguments.
+PASSED: message #1 has no arguments.
+PASSED: message #2 has no arguments.
--- /dev/null
+<html>
+<head>
+<script src="resources/console-clear-arguments-test.js"></script>
+<script>
+
+if (window.layoutTestController) {
+ layoutTestController.waitUntilDone();
+ layoutTestController.dumpAsText();
+}
+
+var loadCount = 0;
+function frameLoaded(event) {
+ ++loadCount;
+ if (loadCount === 1) {
+ document.getElementById('theFrame').src = "about:blank";
+ return;
+ }
+
+ dumpConsoleMessageArgumentCounts();
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+}
+
+</script>
+
+</head>
+<body>
+<p>
+Tests that Web Inspector will discard console message arguments when iframe where the message was
+logged is navigated to a different page.
+</p>
+<iframe id="theFrame" onload="frameLoaded(event)" src="resources/console-clear-arguments-iframe.html"></iframe>
+<div id="output"></div>
+</body>
+</html>
+
CONSOLE MESSAGE: line 4: [object Window]
Tests that console message arguments will be cleared when iframe where the messages were created is removed.
-A message with first argument string resources/console-clear-arguments-iframe.html:2
-2011 resources/console-clear-arguments-iframe.html:3
-[object Window] resources/console-clear-arguments-iframe.html:4
-
+PASSED: found argument counts for 3 messages
+PASSED: message #0 has no arguments.
+PASSED: message #1 has no arguments.
+PASSED: message #2 has no arguments.
<html>
<head>
-<script src="../inspector/inspector-test.js"></script>
-<script src="../inspector/console-test.js"></script>
+<script src="resources/console-clear-arguments-test.js"></script>
<script>
-if (window.layoutTestController)
+if (window.layoutTestController) {
layoutTestController.waitUntilDone();
+ layoutTestController.dumpAsText();
+}
function removeIFrame()
{
container.removeChild(child);
child = container.firstChild;
}
+ dumpConsoleMessageArgumentCounts();
if (window.layoutTestController)
- layoutTestController.showWebInspector();
- runTest();
+ layoutTestController.notifyDone();
}
function createIFrame()
document.getElementById('container').appendChild(iframe);
}
-function test()
-{
- InspectorTest.expandConsoleMessages();
- InspectorTest.dumpConsoleMessages();
- InspectorTest.completeTest();
-}
-
</script>
</head>
<body onload="createIFrame()">
Tests that console message arguments will be cleared when iframe where the messages were
created is removed.
</p>
-<div id="container"/>
+<div id="container"></div>
+<div id="output"></div>
</body>
</html>
--- /dev/null
+function print(text)
+{
+ var output = document.getElementById("output");
+ var div = document.createElement("div");
+ div.textContent = text;
+ output.appendChild(div);
+}
+
+function dumpConsoleMessageArgumentCounts()
+{
+ var consoleMessageArgumentCounts = window.internals.consoleMessageArgumentCounts(document);
+ if (consoleMessageArgumentCounts.length === 3)
+ print("PASSED: found argument counts for 3 messages");
+ else
+ print("FAILED: unexpected number of messages: " + consoleMessageArgumentCounts.length);
+
+ for (var i = 0; i < consoleMessageArgumentCounts.length; i++) {
+ var count = consoleMessageArgumentCounts[i];
+ if (count == 0)
+ print("PASSED: message #" + i + " has no arguments.");
+ else
+ print("FAILED: message #" + i + " has " + count + " arguments.");
+ }
+}
}
}
+InspectorTest.checkConsoleMessagesDontHaveParameters = function()
+{
+ var messages = WebInspector.console.messages;
+ for (var i = 0; i < messages.length; ++i) {
+ var m = messages[i];
+ InspectorTest.addResult("Message[" + i + "]:");
+ InspectorTest.addResult("Message: " + WebInspector.displayNameForURL(m.url) + ":" + m.line + " " + m.message);
+ if ("_parameters" in m) {
+ if (m._parameters)
+ InspectorTest.addResult("FAILED: message parameters list is not empty: " + m._parameters);
+ else
+ InspectorTest.addResult("SUCCESS: message parameters list is empty. ");
+ } else {
+ InspectorTest.addResult("FAILED: didn't find _parameters field in the message.");
+ }
+ }
+}
+
}
+2012-04-27 Yury Semikhatsky <yurys@chromium.org>
+
+ ScriptStateProtectedPtr should not keep a strong reference to the context
+ https://bugs.webkit.org/show_bug.cgi?id=85009
+
+ Delete console message arguments when DOMWindow where the messages were created
+ is reset on its frame.
+
+ Reviewed by Pavel Feldman.
+
+ Test: http/tests/inspector-enabled/console-clear-arguments-on-frame-navigation.html
+
+ * inspector/ConsoleMessage.cpp:
+ (WebCore::ConsoleMessage::addToFrontend):
+ (WebCore::ConsoleMessage::windowCleared):
+ (WebCore::ConsoleMessage::argumentCount):
+ (WebCore):
+ * inspector/ConsoleMessage.h:
+ (ConsoleMessage):
+ * inspector/InspectorConsoleAgent.cpp:
+ (WebCore::InspectorConsoleAgent::consoleMessageArgumentCounts):
+ (WebCore):
+ * inspector/InspectorConsoleAgent.h:
+ (InspectorConsoleAgent):
+ * page/Frame.cpp:
+ (WebCore::Frame::clearDOMWindow):
+ (WebCore::Frame::setDOMWindow):
+ * testing/Internals.cpp:
+ (WebCore):
+ (WebCore::Internals::consoleMessageArgumentCounts):
+ * testing/Internals.h:
+ (Internals):
+ * testing/Internals.idl:
+
2012-04-27 Jochen Eisinger <jochen@chromium.org>
Ensure that there's always a provisional document loader if the frame loader is in provisional state
m_arguments.clear();
}
+unsigned ConsoleMessage::argumentCount()
+{
+ if (m_arguments)
+ return m_arguments->argumentCount();
+ return 0;
+}
+
} // namespace WebCore
#endif // ENABLE(INSPECTOR)
void windowCleared(DOMWindow*);
+ unsigned argumentCount();
+
private:
MessageSource m_source;
MessageType m_type;
addConsoleMessage(adoptPtr(new ConsoleMessage(source, type, level, message, scriptId, lineNumber)));
}
+Vector<unsigned> InspectorConsoleAgent::consoleMessageArgumentCounts()
+{
+ Vector<unsigned> result(m_consoleMessages.size());
+ for (size_t i = 0; i < m_consoleMessages.size(); i++)
+ result[i] = m_consoleMessages[i]->argumentCount();
+ return result;
+}
+
void InspectorConsoleAgent::startTiming(const String& title)
{
// Follow Firebug's behavior of requiring a title that is not null or
void addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, PassRefPtr<ScriptArguments>, PassRefPtr<ScriptCallStack>);
void addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, const String& scriptId, unsigned lineNumber);
+ Vector<unsigned> consoleMessageArgumentCounts();
void startTiming(const String& title);
void stopTiming(const String& title, PassRefPtr<ScriptCallStack>);
void Frame::clearDOMWindow()
{
- if (m_domWindow)
+ if (m_domWindow) {
+ InspectorInstrumentation::frameWindowDiscarded(this, m_domWindow.get());
m_domWindow->clear();
+ }
m_domWindow = 0;
}
void Frame::setDOMWindow(DOMWindow* domWindow)
{
- if (m_domWindow)
+ if (m_domWindow) {
+ InspectorInstrumentation::frameWindowDiscarded(this, m_domWindow.get());
m_domWindow->clear();
+ }
m_domWindow = domWindow;
}
#include "HTMLInputElement.h"
#include "HTMLNames.h"
#include "HTMLTextAreaElement.h"
+#include "InspectorConsoleAgent.h"
#include "InspectorController.h"
#include "InspectorCounters.h"
#include "InspectorInstrumentation.h"
+#include "InstrumentingAgents.h"
#include "InternalSettings.h"
#include "IntRect.h"
#include "Language.h"
{
return InspectorCounters::counterValue(InspectorCounters::DocumentCounter);
}
+
+Vector<String> Internals::consoleMessageArgumentCounts(Document* document) const
+{
+ InstrumentingAgents* instrumentingAgents = instrumentationForPage(document->page());
+ if (!instrumentingAgents)
+ return Vector<String>();
+ InspectorConsoleAgent* consoleAgent = instrumentingAgents->inspectorConsoleAgent();
+ if (!consoleAgent)
+ return Vector<String>();
+ Vector<unsigned> counts = consoleAgent->consoleMessageArgumentCounts();
+ Vector<String> result(counts.size());
+ for (size_t i = 0; i < counts.size(); i++)
+ result[i] = String::number(counts[i]);
+ return result;
+}
#endif // ENABLE(INSPECTOR)
bool Internals::hasGrammarMarker(Document* document, int from, int length, ExceptionCode&)
#if ENABLE(INSPECTOR)
unsigned numberOfLiveNodes() const;
unsigned numberOfLiveDocuments() const;
+ Vector<String> consoleMessageArgumentCounts(Document*) const;
#endif
#if ENABLE(FULLSCREEN_API)
[Conditional=INSPECTOR] unsigned long numberOfLiveNodes();
[Conditional=INSPECTOR] unsigned long numberOfLiveDocuments();
+ [Conditional=INSPECTOR] sequence<String> consoleMessageArgumentCounts(in Document document);
#if defined(ENABLE_FULLSCREEN_API) && ENABLE_FULLSCREEN_API
void webkitWillEnterFullScreenForElement(in Document document, in Element element);