Diff
Modified: trunk/LayoutTests/ChangeLog (200399 => 200400)
--- trunk/LayoutTests/ChangeLog 2016-05-04 01:06:37 UTC (rev 200399)
+++ trunk/LayoutTests/ChangeLog 2016-05-04 01:08:49 UTC (rev 200400)
@@ -1,3 +1,14 @@
+2016-05-03 Joseph Pecoraro <[email protected]>
+
+ Web Inspector: Give console.time/timeEnd a default label and warnings
+ https://bugs.webkit.org/show_bug.cgi?id=157325
+ <rdar://problem/26073290>
+
+ Reviewed by Timothy Hatcher.
+
+ * inspector/console/console-time-expected.txt: Added.
+ * inspector/console/console-time.html: Added.
+
2016-05-03 Joanmarie Diggs <[email protected]>
[ATK] accessibility/document-attributes.html is failing
Added: trunk/LayoutTests/inspector/console/console-time-expected.txt (0 => 200400)
--- trunk/LayoutTests/inspector/console/console-time-expected.txt (rev 0)
+++ trunk/LayoutTests/inspector/console/console-time-expected.txt 2016-05-04 01:08:49 UTC (rev 200400)
@@ -0,0 +1,32 @@
+Tests for the console.time and console.timeEnd APIs.
+
+
+== Running test suite: console.time and console.timeEnd
+-- Running test case: DefaultLabel
+PASS: Should receive a Timing type message.
+PASS: Message should contain the 'default' label name somewhere.
+PASS: Should receive a Timing type message.
+PASS: Message should contain the 'default' label name somewhere.
+PASS: Should receive a Timing type message.
+PASS: Message should contain the 'default' label name somewhere.
+
+-- Running test case: UserLabels
+PASS: Should receive a Timing type message.
+PASS: Message should contain the 'my-label' label name somewhere.
+
+-- Running test case: MultipleTimers
+PASS: Should receive a Timing type message.
+PASS: Message should contain the 'my-label-2' label name somewhere.
+PASS: Should receive a Timing type message.
+PASS: Message should contain the 'my-label-1' label name somewhere.
+
+-- Running test case: WarnWhenExisting
+PASS: Should receive a Timing type message.
+PASS: Should receive a Warning level message
+PASS: Message should contain the 'default' label name somewhere.
+
+-- Running test case: WarnWhenNotExisting
+PASS: Should receive a Timing type message.
+PASS: Should receive a Warning level message.
+PASS: Message should contain the 'default' label name somewhere.
+
Added: trunk/LayoutTests/inspector/console/console-time.html (0 => 200400)
--- trunk/LayoutTests/inspector/console/console-time.html (rev 0)
+++ trunk/LayoutTests/inspector/console/console-time.html 2016-05-04 01:08:49 UTC (rev 200400)
@@ -0,0 +1,129 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script>
+function test()
+{
+ let suite = InspectorTest.createAsyncSuite("console.time and console.timeEnd");
+
+ suite.addTestCase({
+ name: "DefaultLabel",
+ description: "Test that default label works as expected.",
+ test: (resolve, reject) => {
+ let seen = 0;
+ const expected = 3;
+ WebInspector.logManager.addEventListener(WebInspector.LogManager.Event.MessageAdded, handler);
+ function handler(event) {
+ let message = event.data.message;
+ InspectorTest.expectThat(message.type === WebInspector.ConsoleMessage.MessageType.Timing, "Should receive a Timing type message.");
+ InspectorTest.expectThat(message.messageText.includes("default"), "Message should contain the 'default' label name somewhere.");
+ if (++seen === expected) {
+ WebInspector.logManager.removeEventListener(WebInspector.LogManager.Event.MessageAdded, handler);
+ resolve();
+ }
+ }
+
+ InspectorTest.evaluateInPage("console.time()");
+ InspectorTest.evaluateInPage("console.timeEnd()");
+
+ InspectorTest.evaluateInPage("console.time(undefined)");
+ InspectorTest.evaluateInPage("console.timeEnd('default')");
+
+ InspectorTest.evaluateInPage("console.time('default')");
+ InspectorTest.evaluateInPage("console.timeEnd(undefined)");
+ }
+ });
+
+ suite.addTestCase({
+ name: "UserLabels",
+ description: "Test that user labels works as expected.",
+ test: (resolve, reject) => {
+ let seen = 0;
+ const expected = 3;
+ WebInspector.logManager.singleFireEventListener(WebInspector.LogManager.Event.MessageAdded, (event) => {
+ let message = event.data.message;
+ InspectorTest.expectThat(message.type === WebInspector.ConsoleMessage.MessageType.Timing, "Should receive a Timing type message.");
+ InspectorTest.expectThat(message.messageText.includes("my-label"), "Message should contain the 'my-label' label name somewhere.");
+ resolve();
+ });
+
+ InspectorTest.evaluateInPage("console.time('my-label')");
+ InspectorTest.evaluateInPage("console.timeEnd('my-label')");
+ }
+ });
+
+ suite.addTestCase({
+ name: "MultipleTimers",
+ description: "Test that multiple timers running at the same time work as expected.",
+ test: (resolve, reject) => {
+ let seen = 0;
+ const expected = 2;
+ WebInspector.logManager.addEventListener(WebInspector.LogManager.Event.MessageAdded, handler);
+ function handler(event) {
+ let message = event.data.message;
+ let expectedLabel = seen === 0 ? "my-label-2" : "my-label-1";
+ InspectorTest.expectThat(message.type === WebInspector.ConsoleMessage.MessageType.Timing, "Should receive a Timing type message.");
+ InspectorTest.expectThat(message.messageText.includes(expectedLabel), "Message should contain the '" + expectedLabel + "' label name somewhere.");
+ if (++seen === expected) {
+ WebInspector.logManager.removeEventListener(WebInspector.LogManager.Event.MessageAdded, handler);
+ resolve();
+ }
+ }
+
+ InspectorTest.evaluateInPage("console.time('my-label-1')");
+ InspectorTest.evaluateInPage("console.time('my-label-2')");
+ InspectorTest.evaluateInPage("console.timeEnd('my-label-2')");
+ InspectorTest.evaluateInPage("console.timeEnd('my-label-1')");
+ }
+ });
+
+ suite.addTestCase({
+ name: "WarnWhenExisting",
+ description: "Test for a warning when trying to start an already started timer.",
+ test: (resolve, reject) => {
+ WebInspector.logManager.addEventListener(WebInspector.LogManager.Event.MessageAdded, handler);
+ function handler(event) {
+ let message = event.data.message;
+ if (message.level === WebInspector.ConsoleMessage.MessageLevel.Warning) {
+ InspectorTest.expectThat(message.type === WebInspector.ConsoleMessage.MessageType.Timing, "Should receive a Timing type message.");
+ InspectorTest.pass("Should receive a Warning level message");
+ InspectorTest.expectThat(message.messageText.includes("default"), "Message should contain the 'default' label name somewhere.");
+ return;
+ }
+ if (message.type === WebInspector.ConsoleMessage.MessageType.Timing) {
+ WebInspector.logManager.removeEventListener(WebInspector.LogManager.Event.MessageAdded, handler);
+ resolve();
+ }
+ }
+
+ InspectorTest.evaluateInPage("console.time()");
+ InspectorTest.evaluateInPage("console.time()"); // Warning
+ InspectorTest.evaluateInPage("console.timeEnd()");
+ }
+ });
+
+ suite.addTestCase({
+ name: "WarnWhenNotExisting",
+ description: "Test for a warning when trying to start an already started timer.",
+ test: (resolve, reject) => {
+ WebInspector.logManager.singleFireEventListener(WebInspector.LogManager.Event.MessageAdded, (event) => {
+ let message = event.data.message;
+ InspectorTest.expectThat(message.type === WebInspector.ConsoleMessage.MessageType.Timing, "Should receive a Timing type message.");
+ InspectorTest.expectThat(message.level === WebInspector.ConsoleMessage.MessageLevel.Warning, "Should receive a Warning level message.");
+ InspectorTest.expectThat(message.messageText.includes("default"), "Message should contain the 'default' label name somewhere.");
+ resolve();
+ });
+
+ InspectorTest.evaluateInPage("console.timeEnd()");
+ }
+ });
+
+ suite.runTestCasesAndFinish();
+}
+</script>
+</head>
+<body _onload_="runTest()">
+<p>Tests for the console.time and console.timeEnd APIs.</p>
+</body>
+</html>
Modified: trunk/Source/_javascript_Core/ChangeLog (200399 => 200400)
--- trunk/Source/_javascript_Core/ChangeLog 2016-05-04 01:06:37 UTC (rev 200399)
+++ trunk/Source/_javascript_Core/ChangeLog 2016-05-04 01:08:49 UTC (rev 200400)
@@ -1,3 +1,27 @@
+2016-05-03 Joseph Pecoraro <[email protected]>
+
+ Web Inspector: Give console.time/timeEnd a default label and warnings
+ https://bugs.webkit.org/show_bug.cgi?id=157325
+ <rdar://problem/26073290>
+
+ Reviewed by Timothy Hatcher.
+
+ Provide more user friendly console.time/timeEnd. The timer name
+ is now optional, and is "default" if not provided. Also provide
+ warnings when attempting to start an already started timer,
+ or stop a timer that does not exist.
+
+ * inspector/agents/InspectorConsoleAgent.cpp:
+ (Inspector::InspectorConsoleAgent::startTiming):
+ (Inspector::InspectorConsoleAgent::stopTiming):
+ Warnings for bad cases.
+
+ * runtime/ConsoleObject.cpp:
+ (JSC::defaultLabelString):
+ (JSC::consoleProtoFuncTime):
+ (JSC::consoleProtoFuncTimeEnd):
+ Optional label becomes "default".
+
2016-05-03 Xan Lopez <[email protected]>
Fix the ENABLE(WEBASSEMBLY) build
Modified: trunk/Source/_javascript_Core/inspector/agents/InspectorConsoleAgent.cpp (200399 => 200400)
--- trunk/Source/_javascript_Core/inspector/agents/InspectorConsoleAgent.cpp 2016-05-04 01:06:37 UTC (rev 200399)
+++ trunk/Source/_javascript_Core/inspector/agents/InspectorConsoleAgent.cpp 2016-05-04 01:08:49 UTC (rev 200400)
@@ -128,24 +128,32 @@
void InspectorConsoleAgent::startTiming(const String& title)
{
- // Follow Firebug's behavior of requiring a title that is not null or
- // undefined for timing functions
+ ASSERT(!title.isNull());
if (title.isNull())
return;
- m_times.add(title, monotonicallyIncreasingTime());
+ auto result = m_times.add(title, monotonicallyIncreasingTime());
+
+ if (!result.isNewEntry) {
+ // FIXME: Send an enum to the frontend for localization?
+ String warning = makeString("Timer \"", title, "\" already exists");
+ addMessageToConsole(std::make_unique<ConsoleMessage>(MessageSource::ConsoleAPI, MessageType::Timing, MessageLevel::Warning, warning));
+ }
}
void InspectorConsoleAgent::stopTiming(const String& title, PassRefPtr<ScriptCallStack> callStack)
{
- // Follow Firebug's behavior of requiring a title that is not null or
- // undefined for timing functions
+ ASSERT(!title.isNull());
if (title.isNull())
return;
- HashMap<String, double>::iterator it = m_times.find(title);
- if (it == m_times.end())
+ auto it = m_times.find(title);
+ if (it == m_times.end()) {
+ // FIXME: Send an enum to the frontend for localization?
+ String warning = makeString("Timer \"", title, "\" does not exist");
+ addMessageToConsole(std::make_unique<ConsoleMessage>(MessageSource::ConsoleAPI, MessageType::Timing, MessageLevel::Warning, warning));
return;
+ }
double startTime = it->value;
m_times.remove(it);
Modified: trunk/Source/_javascript_Core/runtime/ConsoleObject.cpp (200399 => 200400)
--- trunk/Source/_javascript_Core/runtime/ConsoleObject.cpp 2016-05-04 01:06:37 UTC (rev 200399)
+++ trunk/Source/_javascript_Core/runtime/ConsoleObject.cpp 2016-05-04 01:08:49 UTC (rev 200400)
@@ -284,19 +284,28 @@
return JSValue::encode(jsUndefined());
}
+static String valueOrDefaultLabelString(ExecState* exec, JSValue value)
+{
+ if (value.isUndefined())
+ return ASCIILiteral("default");
+ return value.toString(exec)->value(exec);
+}
+
static EncodedJSValue JSC_HOST_CALL consoleProtoFuncTime(ExecState* exec)
{
ConsoleClient* client = exec->lexicalGlobalObject()->consoleClient();
if (!client)
return JSValue::encode(jsUndefined());
+ String title;
if (exec->argumentCount() < 1)
- return throwVMError(exec, createNotEnoughArgumentsError(exec));
+ title = ASCIILiteral("default");
+ else {
+ title = valueOrDefaultLabelString(exec, exec->argument(0));
+ if (exec->hadException())
+ return JSValue::encode(jsUndefined());
+ }
- const String& title(valueToStringWithUndefinedOrNullCheck(exec, exec->argument(0)));
- if (exec->hadException())
- return JSValue::encode(jsUndefined());
-
client->time(exec, title);
return JSValue::encode(jsUndefined());
}
@@ -307,13 +316,15 @@
if (!client)
return JSValue::encode(jsUndefined());
+ String title;
if (exec->argumentCount() < 1)
- return throwVMError(exec, createNotEnoughArgumentsError(exec));
+ title = ASCIILiteral("default");
+ else {
+ title = valueOrDefaultLabelString(exec, exec->argument(0));
+ if (exec->hadException())
+ return JSValue::encode(jsUndefined());
+ }
- const String& title(valueToStringWithUndefinedOrNullCheck(exec, exec->argument(0)));
- if (exec->hadException())
- return JSValue::encode(jsUndefined());
-
client->timeEnd(exec, title);
return JSValue::encode(jsUndefined());
}
Modified: trunk/Source/WebInspectorUI/ChangeLog (200399 => 200400)
--- trunk/Source/WebInspectorUI/ChangeLog 2016-05-04 01:06:37 UTC (rev 200399)
+++ trunk/Source/WebInspectorUI/ChangeLog 2016-05-04 01:08:49 UTC (rev 200400)
@@ -1,5 +1,16 @@
2016-05-03 Joseph Pecoraro <[email protected]>
+ Web Inspector: Give console.time/timeEnd a default label and warnings
+ https://bugs.webkit.org/show_bug.cgi?id=157325
+ <rdar://problem/26073290>
+
+ Reviewed by Timothy Hatcher.
+
+ * UserInterface/Models/NativeFunctionParameters.js:
+ Update the convenience signature.
+
+2016-05-03 Joseph Pecoraro <[email protected]>
+
Web Inspector: Update window.console function API description strings in Console
https://bugs.webkit.org/show_bug.cgi?id=157298
Modified: trunk/Source/WebInspectorUI/UserInterface/Models/NativeFunctionParameters.js (200399 => 200400)
--- trunk/Source/WebInspectorUI/UserInterface/Models/NativeFunctionParameters.js 2016-05-04 01:06:37 UTC (rev 200399)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/NativeFunctionParameters.js 2016-05-04 01:08:49 UTC (rev 200400)
@@ -175,8 +175,8 @@
profile: "name",
profileEnd: "name",
table: "data, [columns]",
- time: "name",
- timeEnd: "name",
+ time: "name = \"default\"",
+ timeEnd: "name = \"default\"",
timeStamp: "[label]",
trace: "message, [...values]",
warn: "message, [...values]",