Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

Commit

Permalink
WebKit: Support multiple console.log arguments.
Browse files Browse the repository at this point in the history
  • Loading branch information
ariya committed Mar 9, 2012
1 parent ac90639 commit ac699a4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/qt/src/3rdparty/webkit/Source/WebCore/page/Console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,12 @@ void Console::addMessage(MessageType type, MessageLevel level, PassRefPtr<Script
}

String message;
if (arguments->getFirstArgumentAsString(message))
page->chrome()->client()->addMessageToConsole(JSMessageSource, type, level, message, lastCaller.lineNumber(), lastCaller.sourceURL());
for (unsigned i = 0; i < arguments->argumentCount(); ++i) {
message.append(arguments->argumentAt(i).toString(arguments->globalState()));
if (i < arguments->argumentCount() - 1)
message.append(' ');
}
page->chrome()->client()->addMessageToConsole(JSMessageSource, type, level, message, lastCaller.lineNumber(), lastCaller.sourceURL());

InspectorInstrumentation::addMessageToConsole(page, JSMessageSource, type, level, message, arguments, callStack);
}
Expand Down
16 changes: 16 additions & 0 deletions test/webpage-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,22 @@ describe("WebPage object", function() {
expect(fileName).toEqual('README.md');
});
});

it("should support console.log with multiple arguments", function() {
var message;
runs(function() {
page.onConsoleMessage = function (msg) {
message = msg;
}
});

waits(50);

runs(function() {
page.evaluate(function () {console.log('answer', 42)});
expect(message).toEqual("answer 42");
});
});
});

describe("WebPage construction with options", function () {
Expand Down

1 comment on commit ac699a4

@MDCore
Copy link

@MDCore MDCore commented on ac699a4 Mar 9, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great!

Please sign in to comment.