Changeset 246876 in webkit
- Timestamp:
- Jun 27, 2019 1:25:04 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r246875 r246876 1 2019-06-27 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: throw an error if console.count/console.countReset is called with an object that throws an error from toString 4 https://bugs.webkit.org/show_bug.cgi?id=199252 5 6 Reviewed by Joseph Pecoraro. 7 8 * inspector/console/console-count.html: 9 * inspector/console/console-count-expected.txt: 10 * inspector/console/console-api-expected.txt: 11 1 12 2019-06-27 Saam Barati <sbarati@apple.com> 2 13 -
trunk/LayoutTests/inspector/console/console-api-expected.txt
r208009 r246876 586 586 "_source": "console-api", 587 587 "_level": "debug", 588 "_messageText": " Global: 1",588 "_messageText": "default: 1", 589 589 "_type": "log", 590 590 "_url": null, … … 600 600 "_source": "console-api", 601 601 "_level": "debug", 602 "_messageText": "Global: 2", 602 "_messageText": "default: 2", 603 "_type": "log", 604 "_url": null, 605 "_line": 3, 606 "_column": 14, 607 "_repeatCount": 1, 608 "_stackTrace": "<filtered>", 609 "_request": null 610 } 611 612 STEP: console.count("default") 613 { 614 "_source": "console-api", 615 "_level": "debug", 616 "_messageText": "default: 3", 603 617 "_type": "log", 604 618 "_url": null, -
trunk/LayoutTests/inspector/console/console-api.html
r236766 r246876 35 35 "console.count()", 36 36 "console.count()", 37 "console.count(\"default\")", 37 38 "console.count('')", 38 39 "console.count(' ')", -
trunk/LayoutTests/inspector/console/console-count-expected.txt
r246850 r246876 4 4 == Running test suite: console.count 5 5 -- Running test case: console.count.NoArguments 6 Global: 17 Global: 28 Global: 39 Global: 410 Global: 511 Global: 612 Global: 713 Global: 814 Global: 915 Global: 1016 Global: 1117 Global: 1218 Global: 1319 Global: 1420 Global: 1521 Global: 166 default: 1 7 default: 2 8 default: 3 9 default: 4 10 default: 5 11 default: 6 12 default: 7 13 default: 8 14 default: 9 15 default: 10 16 default: 11 17 default: 12 18 default: 13 19 default: 14 20 default: 15 21 default: 16 22 22 23 23 -- Running test case: console.count.WithLabel -
trunk/LayoutTests/inspector/console/console-count.html
r246850 r246876 41 41 suite.addTestCase({ 42 42 name: "console.count.NoArguments", 43 description: "No arguments increments a shared global counter.",43 description: "No arguments uses the default label.", 44 44 test(resolve, reject) { 45 45 let seen = 0; … … 56 56 57 57 InspectorTest.evaluateInPage(`triggerCountNoArguments()`); // 15 58 InspectorTest.evaluateInPage(`console.count( )`); // 158 InspectorTest.evaluateInPage(`console.count("default")`); // 16 59 59 } 60 60 }); -
trunk/Source/JavaScriptCore/ChangeLog
r246874 r246876 1 2019-06-27 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: throw an error if console.count/console.countReset is called with an object that throws an error from toString 4 https://bugs.webkit.org/show_bug.cgi?id=199252 5 6 Reviewed by Joseph Pecoraro. 7 8 Parse the arguments passed to `console.count` and `console.countReset` before sending it to 9 the `ConsoleClient` so that an error can be thrown if the first argument doesn't `toString` 10 nicely (e.g. without throwing an error). 11 12 Generate call stacks for `console.countReset` to match other `console` methods. Also do this 13 for `console.time`, `console.timeLog`, and `console.timeEnd`. Limit the call stack to only 14 have the top frame, so no unnecessary/extra data is sent to the frontend (right now, only 15 the call location is displayed). 16 17 Rename `title` to `label` for `console.time`, `console.timeLog`, and `console.timeEnd` to 18 better match the spec. 19 20 * runtime/ConsoleClient.h: 21 * runtime/ConsoleObject.cpp: 22 (JSC::valueOrDefaultLabelString): 23 (JSC::consoleProtoFuncCount): 24 (JSC::consoleProtoFuncCountReset): 25 (JSC::consoleProtoFuncTime): 26 (JSC::consoleProtoFuncTimeLog): 27 (JSC::consoleProtoFuncTimeEnd): 28 29 * inspector/JSGlobalObjectConsoleClient.h: 30 * inspector/JSGlobalObjectConsoleClient.cpp: 31 (Inspector::JSGlobalObjectConsoleClient::count): 32 (Inspector::JSGlobalObjectConsoleClient::countReset): 33 (Inspector::JSGlobalObjectConsoleClient::time): 34 (Inspector::JSGlobalObjectConsoleClient::timeLog): 35 (Inspector::JSGlobalObjectConsoleClient::timeEnd): 36 37 * inspector/agents/InspectorConsoleAgent.h: 38 * inspector/agents/InspectorConsoleAgent.cpp: 39 (Inspector::InspectorConsoleAgent::startTiming): 40 (Inspector::InspectorConsoleAgent::logTiming): 41 (Inspector::InspectorConsoleAgent::stopTiming): 42 (Inspector::InspectorConsoleAgent::count): 43 (Inspector::InspectorConsoleAgent::countReset): 44 (Inspector::InspectorConsoleAgent::getCounterLabel): Deleted. 45 46 * inspector/ConsoleMessage.h: 47 * inspector/ConsoleMessage.cpp: 48 (Inspector::ConsoleMessage::ConsoleMessage): 49 Allow `ConsoleMessage`s to be created with both `ScriptArguments` and a `ScriptCallStack`. 50 1 51 2019-06-27 Fujii Hironori <Hironori.Fujii@sony.com> 2 52 -
trunk/Source/JavaScriptCore/inspector/ConsoleMessage.cpp
r242992 r246876 83 83 } 84 84 85 ConsoleMessage::ConsoleMessage(MessageSource source, MessageType type, MessageLevel level, const String& message, Ref<ScriptArguments>&& arguments, Ref<ScriptCallStack>&& callStack, unsigned long requestIdentifier) 86 : m_source(source) 87 , m_type(type) 88 , m_level(level) 89 , m_message(message) 90 , m_arguments(WTFMove(arguments)) 91 , m_callStack(WTFMove(callStack)) 92 , m_url() 93 , m_requestId(IdentifiersFactory::requestId(requestIdentifier)) 94 { 95 const ScriptCallFrame* frame = m_callStack ? m_callStack->firstNonNativeCallFrame() : nullptr; 96 if (frame) { 97 m_url = frame->sourceURL(); 98 m_line = frame->lineNumber(); 99 m_column = frame->columnNumber(); 100 } 101 } 102 85 103 ConsoleMessage::ConsoleMessage(MessageSource source, MessageType type, MessageLevel level, const String& message, Ref<ScriptArguments>&& arguments, JSC::ExecState* state, unsigned long requestIdentifier) 86 104 : m_source(source) -
trunk/Source/JavaScriptCore/inspector/ConsoleMessage.h
r242992 r246876 56 56 ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& message, const String& url, unsigned line, unsigned column, JSC::ExecState* = nullptr, unsigned long requestIdentifier = 0); 57 57 ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& message, Ref<ScriptCallStack>&&, unsigned long requestIdentifier = 0); 58 ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& message, Ref<ScriptArguments>&&, Ref<ScriptCallStack>&&, unsigned long requestIdentifier = 0); 58 59 ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& message, Ref<ScriptArguments>&&, JSC::ExecState* = nullptr, unsigned long requestIdentifier = 0); 59 60 ConsoleMessage(MessageSource, MessageType, MessageLevel, Vector<JSONLogValue>&&, JSC::ExecState*, unsigned long requestIdentifier = 0); -
trunk/Source/JavaScriptCore/inspector/JSGlobalObjectConsoleClient.cpp
r246850 r246876 71 71 } 72 72 73 void JSGlobalObjectConsoleClient::count(ExecState* exec, Ref<ScriptArguments>&& arguments)73 void JSGlobalObjectConsoleClient::count(ExecState* exec, const String& label) 74 74 { 75 m_consoleAgent->count(exec, WTFMove(arguments));75 m_consoleAgent->count(exec, label); 76 76 } 77 77 78 void JSGlobalObjectConsoleClient::countReset(ExecState* exec, Ref<ScriptArguments>&& arguments)78 void JSGlobalObjectConsoleClient::countReset(ExecState* exec, const String& label) 79 79 { 80 m_consoleAgent->countReset(exec, WTFMove(arguments));80 m_consoleAgent->countReset(exec, label); 81 81 } 82 82 … … 154 154 } 155 155 156 void JSGlobalObjectConsoleClient::time(ExecState* , const String& title)156 void JSGlobalObjectConsoleClient::time(ExecState* exec, const String& label) 157 157 { 158 m_consoleAgent->startTiming( title);158 m_consoleAgent->startTiming(exec, label); 159 159 } 160 160 161 void JSGlobalObjectConsoleClient::timeLog(ExecState* , const String& title, Ref<ScriptArguments>&& arguments)161 void JSGlobalObjectConsoleClient::timeLog(ExecState* exec, const String& label, Ref<ScriptArguments>&& arguments) 162 162 { 163 m_consoleAgent->logTiming( title, WTFMove(arguments));163 m_consoleAgent->logTiming(exec, label, WTFMove(arguments)); 164 164 } 165 165 166 void JSGlobalObjectConsoleClient::timeEnd(ExecState* exec, const String& title)166 void JSGlobalObjectConsoleClient::timeEnd(ExecState* exec, const String& label) 167 167 { 168 m_consoleAgent->stopTiming( title, createScriptCallStackForConsole(exec, 1));168 m_consoleAgent->stopTiming(exec, label); 169 169 } 170 170 -
trunk/Source/JavaScriptCore/inspector/JSGlobalObjectConsoleClient.h
r246850 r246876 50 50 protected: 51 51 void messageWithTypeAndLevel(MessageType, MessageLevel, JSC::ExecState*, Ref<ScriptArguments>&&) override; 52 void count(JSC::ExecState*, Ref<ScriptArguments>&&) override;53 void countReset(JSC::ExecState*, Ref<ScriptArguments>&&) override;52 void count(JSC::ExecState*, const String& label) override; 53 void countReset(JSC::ExecState*, const String& label) override; 54 54 void profile(JSC::ExecState*, const String& title) override; 55 55 void profileEnd(JSC::ExecState*, const String& title) override; 56 56 void takeHeapSnapshot(JSC::ExecState*, const String& title) override; 57 void time(JSC::ExecState*, const String& title) override;58 void timeLog(JSC::ExecState*, const String& title, Ref<ScriptArguments>&& arguments) override;59 void timeEnd(JSC::ExecState*, const String& title) override;57 void time(JSC::ExecState*, const String& label) override; 58 void timeLog(JSC::ExecState*, const String& label, Ref<ScriptArguments>&&) override; 59 void timeEnd(JSC::ExecState*, const String& label) override; 60 60 void timeStamp(JSC::ExecState*, Ref<ScriptArguments>&&) override; 61 61 void record(JSC::ExecState*, Ref<ScriptArguments>&&) override; -
trunk/Source/JavaScriptCore/inspector/agents/InspectorConsoleAgent.cpp
r246850 r246876 127 127 } 128 128 129 void InspectorConsoleAgent::startTiming( const String& title)130 { 131 if (!m_injectedScriptManager.inspectorEnvironment().developerExtrasEnabled()) 132 return; 133 134 ASSERT(! title.isNull());135 if ( title.isNull())136 return; 137 138 auto result = m_times.add( title, MonotonicTime::now());129 void InspectorConsoleAgent::startTiming(JSC::ExecState* exec, const String& label) 130 { 131 if (!m_injectedScriptManager.inspectorEnvironment().developerExtrasEnabled()) 132 return; 133 134 ASSERT(!label.isNull()); 135 if (label.isNull()) 136 return; 137 138 auto result = m_times.add(label, MonotonicTime::now()); 139 139 140 140 if (!result.isNewEntry) { 141 141 // FIXME: Send an enum to the frontend for localization? 142 String warning = makeString("Timer \"", title, "\" already exists"); 143 addMessageToConsole(std::make_unique<ConsoleMessage>(MessageSource::ConsoleAPI, MessageType::Timing, MessageLevel::Warning, warning)); 144 } 145 } 146 147 void InspectorConsoleAgent::logTiming(const String& title, Ref<ScriptArguments>&& arguments) 148 { 149 if (!m_injectedScriptManager.inspectorEnvironment().developerExtrasEnabled()) 150 return; 151 152 ASSERT(!title.isNull()); 153 if (title.isNull()) 154 return; 155 156 auto it = m_times.find(title); 142 String warning = makeString("Timer \"", label, "\" already exists"); 143 addMessageToConsole(std::make_unique<ConsoleMessage>(MessageSource::ConsoleAPI, MessageType::Timing, MessageLevel::Warning, warning, createScriptCallStackForConsole(exec, 1))); 144 } 145 } 146 147 void InspectorConsoleAgent::logTiming(JSC::ExecState* exec, const String& label, Ref<ScriptArguments>&& arguments) 148 { 149 if (!m_injectedScriptManager.inspectorEnvironment().developerExtrasEnabled()) 150 return; 151 152 ASSERT(!label.isNull()); 153 if (label.isNull()) 154 return; 155 156 auto callStack = createScriptCallStackForConsole(exec, 1); 157 158 auto it = m_times.find(label); 157 159 if (it == m_times.end()) { 158 160 // FIXME: Send an enum to the frontend for localization? 159 String warning = makeString("Timer \"", title, "\" does not exist");160 addMessageToConsole(std::make_unique<ConsoleMessage>(MessageSource::ConsoleAPI, MessageType::Timing, MessageLevel::Warning, warning ));161 String warning = makeString("Timer \"", label, "\" does not exist"); 162 addMessageToConsole(std::make_unique<ConsoleMessage>(MessageSource::ConsoleAPI, MessageType::Timing, MessageLevel::Warning, warning, WTFMove(callStack))); 161 163 return; 162 164 } … … 164 166 MonotonicTime startTime = it->value; 165 167 Seconds elapsed = MonotonicTime::now() - startTime; 166 String message = makeString(title, ": ", FormattedNumber::fixedWidth(elapsed.milliseconds(), 3), "ms"); 167 addMessageToConsole(std::make_unique<ConsoleMessage>(MessageSource::ConsoleAPI, MessageType::Timing, MessageLevel::Debug, message, WTFMove(arguments))); 168 } 169 170 void InspectorConsoleAgent::stopTiming(const String& title, Ref<ScriptCallStack>&& callStack) 171 { 172 if (!m_injectedScriptManager.inspectorEnvironment().developerExtrasEnabled()) 173 return; 174 175 ASSERT(!title.isNull()); 176 if (title.isNull()) 177 return; 178 179 auto it = m_times.find(title); 168 String message = makeString(label, ": ", FormattedNumber::fixedWidth(elapsed.milliseconds(), 3), "ms"); 169 addMessageToConsole(std::make_unique<ConsoleMessage>(MessageSource::ConsoleAPI, MessageType::Timing, MessageLevel::Debug, message, WTFMove(arguments), WTFMove(callStack))); 170 } 171 172 void InspectorConsoleAgent::stopTiming(JSC::ExecState* exec, const String& label) 173 { 174 if (!m_injectedScriptManager.inspectorEnvironment().developerExtrasEnabled()) 175 return; 176 177 ASSERT(!label.isNull()); 178 if (label.isNull()) 179 return; 180 181 auto callStack = createScriptCallStackForConsole(exec, 1); 182 183 auto it = m_times.find(label); 180 184 if (it == m_times.end()) { 181 185 // FIXME: Send an enum to the frontend for localization? 182 String warning = makeString("Timer \"", title, "\" does not exist");183 addMessageToConsole(std::make_unique<ConsoleMessage>(MessageSource::ConsoleAPI, MessageType::Timing, MessageLevel::Warning, warning ));186 String warning = makeString("Timer \"", label, "\" does not exist"); 187 addMessageToConsole(std::make_unique<ConsoleMessage>(MessageSource::ConsoleAPI, MessageType::Timing, MessageLevel::Warning, warning, WTFMove(callStack))); 184 188 return; 185 189 } … … 187 191 MonotonicTime startTime = it->value; 188 192 Seconds elapsed = MonotonicTime::now() - startTime; 189 String message = makeString( title, ": ", FormattedNumber::fixedWidth(elapsed.milliseconds(), 3), "ms");193 String message = makeString(label, ": ", FormattedNumber::fixedWidth(elapsed.milliseconds(), 3), "ms"); 190 194 addMessageToConsole(std::make_unique<ConsoleMessage>(MessageSource::ConsoleAPI, MessageType::Timing, MessageLevel::Debug, message, WTFMove(callStack))); 191 195 … … 209 213 } 210 214 211 void InspectorConsoleAgent::getCounterLabel(Ref<ScriptArguments>&& arguments, String& title, String& identifier) 212 { 213 if (!arguments->argumentCount()) { 214 // '@' prefix for engine generated labels. 215 title = "Global"_s; 216 identifier = makeString('@', title); 217 } else { 218 // '#' prefix for user labels. 219 arguments->getFirstArgumentAsString(title); 220 identifier = makeString('#', title); 221 } 222 } 223 224 void InspectorConsoleAgent::count(JSC::ExecState* state, Ref<ScriptArguments>&& arguments) 225 { 226 if (!m_injectedScriptManager.inspectorEnvironment().developerExtrasEnabled()) 227 return; 228 229 String title; 230 String identifier; 231 getCounterLabel(WTFMove(arguments), title, identifier); 232 233 auto result = m_counts.add(identifier, 1); 215 void InspectorConsoleAgent::count(JSC::ExecState* exec, const String& label) 216 { 217 if (!m_injectedScriptManager.inspectorEnvironment().developerExtrasEnabled()) 218 return; 219 220 auto result = m_counts.add(label, 1); 234 221 if (!result.isNewEntry) 235 222 result.iterator->value += 1; … … 237 224 // FIXME: Web Inspector should have a better UI for counters, but for now we just log an updated counter value. 238 225 239 String message = makeString(title, ": ", result.iterator->value); 240 Ref<ScriptCallStack> callStack = createScriptCallStackForConsole(state); 241 addMessageToConsole(std::make_unique<ConsoleMessage>(MessageSource::ConsoleAPI, MessageType::Log, MessageLevel::Debug, message, WTFMove(callStack))); 242 } 243 244 void InspectorConsoleAgent::countReset(JSC::ExecState*, Ref<ScriptArguments>&& arguments) 245 { 246 if (!m_injectedScriptManager.inspectorEnvironment().developerExtrasEnabled()) 247 return; 248 249 String title; 250 String identifier; 251 getCounterLabel(WTFMove(arguments), title, identifier); 252 253 auto it = m_counts.find(identifier); 226 String message = makeString(label, ": ", result.iterator->value); 227 addMessageToConsole(std::make_unique<ConsoleMessage>(MessageSource::ConsoleAPI, MessageType::Log, MessageLevel::Debug, message, createScriptCallStackForConsole(exec, 1))); 228 } 229 230 void InspectorConsoleAgent::countReset(JSC::ExecState* exec, const String& label) 231 { 232 if (!m_injectedScriptManager.inspectorEnvironment().developerExtrasEnabled()) 233 return; 234 235 auto it = m_counts.find(label); 254 236 if (it == m_counts.end()) { 255 237 // FIXME: Send an enum to the frontend for localization? 256 String warning = makeString("Counter \"", title, "\" does not exist");257 addMessageToConsole(std::make_unique<ConsoleMessage>(MessageSource::ConsoleAPI, MessageType::Log, MessageLevel::Warning, warning ));238 String warning = makeString("Counter \"", label, "\" does not exist"); 239 addMessageToConsole(std::make_unique<ConsoleMessage>(MessageSource::ConsoleAPI, MessageType::Log, MessageLevel::Warning, warning, createScriptCallStackForConsole(exec, 1))); 258 240 return; 259 241 } -
trunk/Source/JavaScriptCore/inspector/agents/InspectorConsoleAgent.h
r246850 r246876 71 71 void addMessageToConsole(std::unique_ptr<ConsoleMessage>); 72 72 73 void startTiming( const String& title);74 void logTiming( const String& title, Ref<ScriptArguments>&&);75 void stopTiming( const String& title, Ref<ScriptCallStack>&&);73 void startTiming(JSC::ExecState*, const String& label); 74 void logTiming(JSC::ExecState*, const String& label, Ref<ScriptArguments>&&); 75 void stopTiming(JSC::ExecState*, const String& label); 76 76 void takeHeapSnapshot(const String& title); 77 void count(JSC::ExecState*, Ref<ScriptArguments>&&);78 void countReset(JSC::ExecState*, Ref<ScriptArguments>&&);77 void count(JSC::ExecState*, const String& label); 78 void countReset(JSC::ExecState*, const String& label); 79 79 80 80 void getLoggingChannels(ErrorString&, RefPtr<JSON::ArrayOf<Protocol::Console::Channel>>&) override; … … 82 82 83 83 protected: 84 void getCounterLabel(Ref<ScriptArguments>&&, String& title, String& identifier);85 84 void addConsoleMessage(std::unique_ptr<ConsoleMessage>); 86 85 -
trunk/Source/JavaScriptCore/runtime/ConsoleClient.h
r246850 r246876 56 56 57 57 virtual void messageWithTypeAndLevel(MessageType, MessageLevel, JSC::ExecState*, Ref<Inspector::ScriptArguments>&&) = 0; 58 virtual void count(ExecState*, Ref<Inspector::ScriptArguments>&&) = 0;59 virtual void countReset(ExecState*, Ref<Inspector::ScriptArguments>&&) = 0;58 virtual void count(ExecState*, const String& label) = 0; 59 virtual void countReset(ExecState*, const String& label) = 0; 60 60 virtual void profile(ExecState*, const String& title) = 0; 61 61 virtual void profileEnd(ExecState*, const String& title) = 0; 62 62 virtual void takeHeapSnapshot(ExecState*, const String& title) = 0; 63 virtual void time(ExecState*, const String& title) = 0;64 virtual void timeLog(ExecState*, const String& title, Ref<Inspector::ScriptArguments>&&) = 0;65 virtual void timeEnd(ExecState*, const String& title) = 0;63 virtual void time(ExecState*, const String& label) = 0; 64 virtual void timeLog(ExecState*, const String& label, Ref<Inspector::ScriptArguments>&&) = 0; 65 virtual void timeEnd(ExecState*, const String& label) = 0; 66 66 virtual void timeStamp(ExecState*, Ref<Inspector::ScriptArguments>&&) = 0; 67 67 virtual void record(ExecState*, Ref<Inspector::ScriptArguments>&&) = 0; -
trunk/Source/JavaScriptCore/runtime/ConsoleObject.cpp
r246850 r246876 34 34 35 35 namespace JSC { 36 37 static String valueOrDefaultLabelString(ExecState* exec) 38 { 39 if (exec->argumentCount() < 1) 40 return "default"_s; 41 42 auto value = exec->argument(0); 43 if (value.isUndefined()) 44 return "default"_s; 45 46 return value.toWTFString(exec); 47 } 36 48 37 49 STATIC_ASSERT_IS_TRIVIALLY_DESTRUCTIBLE(ConsoleObject); … … 220 232 static EncodedJSValue JSC_HOST_CALL consoleProtoFuncCount(ExecState* exec) 221 233 { 222 ConsoleClient* client = exec->lexicalGlobalObject()->consoleClient(); 223 if (!client) 224 return JSValue::encode(jsUndefined()); 225 226 client->count(exec, Inspector::createScriptArguments(exec, 0)); 234 auto scope = DECLARE_THROW_SCOPE(exec->vm()); 235 auto* client = exec->lexicalGlobalObject()->consoleClient(); 236 if (!client) 237 return JSValue::encode(jsUndefined()); 238 239 auto label = valueOrDefaultLabelString(exec); 240 RETURN_IF_EXCEPTION(scope, encodedJSValue()); 241 242 client->count(exec, label); 227 243 return JSValue::encode(jsUndefined()); 228 244 } … … 230 246 static EncodedJSValue JSC_HOST_CALL consoleProtoFuncCountReset(ExecState* exec) 231 247 { 232 ConsoleClient* client = exec->lexicalGlobalObject()->consoleClient(); 233 if (!client) 234 return JSValue::encode(jsUndefined()); 235 236 client->countReset(exec, Inspector::createScriptArguments(exec, 0)); 248 auto scope = DECLARE_THROW_SCOPE(exec->vm()); 249 auto* client = exec->lexicalGlobalObject()->consoleClient(); 250 if (!client) 251 return JSValue::encode(jsUndefined()); 252 253 auto label = valueOrDefaultLabelString(exec); 254 RETURN_IF_EXCEPTION(scope, encodedJSValue()); 255 256 client->countReset(exec, label); 237 257 return JSValue::encode(jsUndefined()); 238 258 } … … 301 321 } 302 322 303 static String valueOrDefaultLabelString(ExecState* exec, JSValue value)304 {305 if (value.isUndefined())306 return "default"_s;307 return value.toWTFString(exec);308 }309 310 323 static EncodedJSValue JSC_HOST_CALL consoleProtoFuncTime(ExecState* exec) 311 324 { 312 VM& vm = exec->vm(); 313 auto scope = DECLARE_THROW_SCOPE(vm); 314 ConsoleClient* client = exec->lexicalGlobalObject()->consoleClient(); 315 if (!client) 316 return JSValue::encode(jsUndefined()); 317 318 String title; 319 if (exec->argumentCount() < 1) 320 title = "default"_s; 321 else { 322 title = valueOrDefaultLabelString(exec, exec->argument(0)); 323 RETURN_IF_EXCEPTION(scope, encodedJSValue()); 324 } 325 326 client->time(exec, title); 325 auto scope = DECLARE_THROW_SCOPE(exec->vm()); 326 auto* client = exec->lexicalGlobalObject()->consoleClient(); 327 if (!client) 328 return JSValue::encode(jsUndefined()); 329 330 auto label = valueOrDefaultLabelString(exec); 331 RETURN_IF_EXCEPTION(scope, encodedJSValue()); 332 333 client->time(exec, label); 327 334 return JSValue::encode(jsUndefined()); 328 335 } … … 330 337 static EncodedJSValue JSC_HOST_CALL consoleProtoFuncTimeLog(ExecState* exec) 331 338 { 332 VM& vm = exec->vm(); 333 auto scope = DECLARE_THROW_SCOPE(vm); 334 ConsoleClient* client = exec->lexicalGlobalObject()->consoleClient(); 335 if (!client) 336 return JSValue::encode(jsUndefined()); 337 338 String title; 339 if (exec->argumentCount() < 1) 340 title = "default"_s; 341 else { 342 title = valueOrDefaultLabelString(exec, exec->argument(0)); 343 RETURN_IF_EXCEPTION(scope, encodedJSValue()); 344 } 345 346 client->timeLog(exec, title, Inspector::createScriptArguments(exec, 1)); 339 auto scope = DECLARE_THROW_SCOPE(exec->vm()); 340 auto* client = exec->lexicalGlobalObject()->consoleClient(); 341 if (!client) 342 return JSValue::encode(jsUndefined()); 343 344 auto label = valueOrDefaultLabelString(exec); 345 RETURN_IF_EXCEPTION(scope, encodedJSValue()); 346 347 client->timeLog(exec, label, Inspector::createScriptArguments(exec, 1)); 347 348 return JSValue::encode(jsUndefined()); 348 349 } … … 350 351 static EncodedJSValue JSC_HOST_CALL consoleProtoFuncTimeEnd(ExecState* exec) 351 352 { 352 VM& vm = exec->vm(); 353 auto scope = DECLARE_THROW_SCOPE(vm); 354 ConsoleClient* client = exec->lexicalGlobalObject()->consoleClient(); 355 if (!client) 356 return JSValue::encode(jsUndefined()); 357 358 String title; 359 if (exec->argumentCount() < 1) 360 title = "default"_s; 361 else { 362 title = valueOrDefaultLabelString(exec, exec->argument(0)); 363 RETURN_IF_EXCEPTION(scope, encodedJSValue()); 364 } 365 366 client->timeEnd(exec, title); 353 auto scope = DECLARE_THROW_SCOPE(exec->vm()); 354 auto* client = exec->lexicalGlobalObject()->consoleClient(); 355 if (!client) 356 return JSValue::encode(jsUndefined()); 357 358 auto label = valueOrDefaultLabelString(exec); 359 RETURN_IF_EXCEPTION(scope, encodedJSValue()); 360 361 client->timeEnd(exec, label); 367 362 return JSValue::encode(jsUndefined()); 368 363 } -
trunk/Source/WebCore/ChangeLog
r246875 r246876 1 2019-06-27 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: throw an error if console.count/console.countReset is called with an object that throws an error from toString 4 https://bugs.webkit.org/show_bug.cgi?id=199252 5 6 Reviewed by Joseph Pecoraro. 7 8 Parse the arguments passed to `console.count` and `console.countReset` before sending it to 9 the `ConsoleClient` so that an error can be thrown if the first argument doesn't `toString` 10 nicely (e.g. without throwing an error). 11 12 Generate call stacks for `console.countReset` to match other `console` methods. Also do this 13 for `console.time`, `console.timeLog`, and `console.timeEnd`. Limit the call stack to only 14 have the top frame, so no unnecessary/extra data is sent to the frontend (right now, only 15 the call location is displayed). 16 17 Rename `title` to `label` for `console.time`, `console.timeLog`, and `console.timeEnd` to 18 better match the spec. 19 20 Updated existing LayoutTests: 21 - inspector/console/console-count.html 22 - inspector/console/console-api.html 23 24 Also covered by existing WPT tests. 25 26 * inspector/InspectorInstrumentation.h: 27 (WebCore::InspectorInstrumentation::consoleCount): 28 (WebCore::InspectorInstrumentation::consoleCountReset): 29 (WebCore::InspectorInstrumentation::startConsoleTiming): 30 (WebCore::InspectorInstrumentation::logConsoleTiming): 31 (WebCore::InspectorInstrumentation::stopConsoleTiming): 32 * inspector/InspectorInstrumentation.cpp: 33 (WebCore::InspectorInstrumentation::consoleCountImpl): 34 (WebCore::InspectorInstrumentation::consoleCountResetImpl): 35 (WebCore::InspectorInstrumentation::startConsoleTimingImpl): 36 (WebCore::InspectorInstrumentation::logConsoleTimingImpl): 37 (WebCore::InspectorInstrumentation::stopConsoleTimingImpl): 38 39 * page/PageConsoleClient.h: 40 * page/PageConsoleClient.cpp: 41 (WebCore::PageConsoleClient::count): 42 (WebCore::PageConsoleClient::countReset): 43 (WebCore::PageConsoleClient::time): 44 (WebCore::PageConsoleClient::timeLog): 45 (WebCore::PageConsoleClient::timeEnd): 46 47 * workers/WorkerConsoleClient.h: 48 * workers/WorkerConsoleClient.cpp: 49 (WebCore::WorkerConsoleClient::count): 50 (WebCore::WorkerConsoleClient::countReset): 51 (WebCore::WorkerConsoleClient::time): 52 (WebCore::WorkerConsoleClient::timeLog): 53 (WebCore::WorkerConsoleClient::timeEnd): 54 55 * worklets/WorkletConsoleClient.h: 56 * worklets/WorkletConsoleClient.cpp: 57 (WebCore::WorkletConsoleClient::count): 58 (WebCore::WorkletConsoleClient::countReset): 59 1 60 2019-06-27 Saam Barati <sbarati@apple.com> 2 61 -
trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp
r246850 r246876 852 852 } 853 853 854 void InspectorInstrumentation::consoleCountImpl(InstrumentingAgents& instrumentingAgents, JSC::ExecState* state, Ref<ScriptArguments>&& arguments)855 { 856 if ( WebConsoleAgent* consoleAgent = instrumentingAgents.webConsoleAgent())857 consoleAgent->count(state, WTFMove(arguments));858 } 859 860 void InspectorInstrumentation::consoleCountResetImpl(InstrumentingAgents& instrumentingAgents, JSC::ExecState* state, Ref<ScriptArguments>&& arguments)861 { 862 if ( WebConsoleAgent* consoleAgent = instrumentingAgents.webConsoleAgent())863 consoleAgent->countReset(state, WTFMove(arguments));854 void InspectorInstrumentation::consoleCountImpl(InstrumentingAgents& instrumentingAgents, JSC::ExecState* state, const String& label) 855 { 856 if (auto* consoleAgent = instrumentingAgents.webConsoleAgent()) 857 consoleAgent->count(state, label); 858 } 859 860 void InspectorInstrumentation::consoleCountResetImpl(InstrumentingAgents& instrumentingAgents, JSC::ExecState* state, const String& label) 861 { 862 if (auto* consoleAgent = instrumentingAgents.webConsoleAgent()) 863 consoleAgent->countReset(state, label); 864 864 } 865 865 … … 870 870 } 871 871 872 void InspectorInstrumentation::startConsoleTimingImpl(InstrumentingAgents& instrumentingAgents, Frame& frame, const String& title)872 void InspectorInstrumentation::startConsoleTimingImpl(InstrumentingAgents& instrumentingAgents, Frame& frame, JSC::ExecState* exec, const String& label) 873 873 { 874 874 if (!instrumentingAgents.inspectorEnvironment().developerExtrasEnabled()) 875 875 return; 876 876 877 if ( InspectorTimelineAgent* timelineAgent = instrumentingAgents.inspectorTimelineAgent())878 timelineAgent->time(frame, title);879 if ( WebConsoleAgent* consoleAgent = instrumentingAgents.webConsoleAgent())880 consoleAgent->startTiming( title);881 } 882 883 void InspectorInstrumentation::startConsoleTimingImpl(InstrumentingAgents& instrumentingAgents, const String& title)877 if (auto* timelineAgent = instrumentingAgents.inspectorTimelineAgent()) 878 timelineAgent->time(frame, label); 879 if (auto* consoleAgent = instrumentingAgents.webConsoleAgent()) 880 consoleAgent->startTiming(exec, label); 881 } 882 883 void InspectorInstrumentation::startConsoleTimingImpl(InstrumentingAgents& instrumentingAgents, JSC::ExecState* exec, const String& label) 884 884 { 885 885 if (!instrumentingAgents.inspectorEnvironment().developerExtrasEnabled()) 886 886 return; 887 887 888 if ( WebConsoleAgent* consoleAgent = instrumentingAgents.webConsoleAgent())889 consoleAgent->startTiming( title);890 } 891 892 void InspectorInstrumentation::logConsoleTimingImpl(InstrumentingAgents& instrumentingAgents, const String& title, Ref<Inspector::ScriptArguments>&& arguments)888 if (auto* consoleAgent = instrumentingAgents.webConsoleAgent()) 889 consoleAgent->startTiming(exec, label); 890 } 891 892 void InspectorInstrumentation::logConsoleTimingImpl(InstrumentingAgents& instrumentingAgents, JSC::ExecState* exec, const String& label, Ref<Inspector::ScriptArguments>&& arguments) 893 893 { 894 894 if (!instrumentingAgents.inspectorEnvironment().developerExtrasEnabled()) 895 895 return; 896 896 897 if ( WebConsoleAgent* consoleAgent = instrumentingAgents.webConsoleAgent())898 consoleAgent->logTiming( title, WTFMove(arguments));899 } 900 901 void InspectorInstrumentation::stopConsoleTimingImpl(InstrumentingAgents& instrumentingAgents, Frame& frame, const String& title, Ref<ScriptCallStack>&& stack)897 if (auto* consoleAgent = instrumentingAgents.webConsoleAgent()) 898 consoleAgent->logTiming(exec, label, WTFMove(arguments)); 899 } 900 901 void InspectorInstrumentation::stopConsoleTimingImpl(InstrumentingAgents& instrumentingAgents, Frame& frame, JSC::ExecState* exec, const String& label) 902 902 { 903 903 if (!instrumentingAgents.inspectorEnvironment().developerExtrasEnabled()) 904 904 return; 905 905 906 if ( WebConsoleAgent* consoleAgent = instrumentingAgents.webConsoleAgent())907 consoleAgent->stopTiming( title, WTFMove(stack));908 if ( InspectorTimelineAgent* timelineAgent = instrumentingAgents.inspectorTimelineAgent())909 timelineAgent->timeEnd(frame, title);910 } 911 912 void InspectorInstrumentation::stopConsoleTimingImpl(InstrumentingAgents& instrumentingAgents, const String& title, Ref<ScriptCallStack>&& stack)906 if (auto* consoleAgent = instrumentingAgents.webConsoleAgent()) 907 consoleAgent->stopTiming(exec, label); 908 if (auto* timelineAgent = instrumentingAgents.inspectorTimelineAgent()) 909 timelineAgent->timeEnd(frame, label); 910 } 911 912 void InspectorInstrumentation::stopConsoleTimingImpl(InstrumentingAgents& instrumentingAgents, JSC::ExecState* exec, const String& label) 913 913 { 914 914 if (!instrumentingAgents.inspectorEnvironment().developerExtrasEnabled()) 915 915 return; 916 916 917 if ( WebConsoleAgent* consoleAgent = instrumentingAgents.webConsoleAgent())918 consoleAgent->stopTiming( title, WTFMove(stack));917 if (auto* consoleAgent = instrumentingAgents.webConsoleAgent()) 918 consoleAgent->stopTiming(exec, label); 919 919 } 920 920 -
trunk/Source/WebCore/inspector/InspectorInstrumentation.h
r246850 r246876 222 222 static void addMessageToConsole(WorkerGlobalScope&, std::unique_ptr<Inspector::ConsoleMessage>); 223 223 224 static void consoleCount(Page&, JSC::ExecState*, Ref<Inspector::ScriptArguments>&&);225 static void consoleCount(WorkerGlobalScope&, JSC::ExecState*, Ref<Inspector::ScriptArguments>&&);226 static void consoleCountReset(Page&, JSC::ExecState*, Ref<Inspector::ScriptArguments>&&);227 static void consoleCountReset(WorkerGlobalScope&, JSC::ExecState*, Ref<Inspector::ScriptArguments>&&);224 static void consoleCount(Page&, JSC::ExecState*, const String& label); 225 static void consoleCount(WorkerGlobalScope&, JSC::ExecState*, const String& label); 226 static void consoleCountReset(Page&, JSC::ExecState*, const String& label); 227 static void consoleCountReset(WorkerGlobalScope&, JSC::ExecState*, const String& label); 228 228 229 229 static void takeHeapSnapshot(Frame&, const String& title); 230 static void startConsoleTiming(Frame&, const String& title);231 static void startConsoleTiming(WorkerGlobalScope&, const String& title);232 static void logConsoleTiming(Frame&, const String& title, Ref<Inspector::ScriptArguments>&&);233 static void logConsoleTiming(WorkerGlobalScope&, const String& title, Ref<Inspector::ScriptArguments>&&);234 static void stopConsoleTiming(Frame&, const String& title, Ref<Inspector::ScriptCallStack>&&);235 static void stopConsoleTiming(WorkerGlobalScope&, const String& title, Ref<Inspector::ScriptCallStack>&&);230 static void startConsoleTiming(Frame&, JSC::ExecState*, const String& label); 231 static void startConsoleTiming(WorkerGlobalScope&, JSC::ExecState*, const String& label); 232 static void logConsoleTiming(Frame&, JSC::ExecState*, const String& label, Ref<Inspector::ScriptArguments>&&); 233 static void logConsoleTiming(WorkerGlobalScope&, JSC::ExecState*, const String& label, Ref<Inspector::ScriptArguments>&&); 234 static void stopConsoleTiming(Frame&, JSC::ExecState*, const String& label); 235 static void stopConsoleTiming(WorkerGlobalScope&, JSC::ExecState*, const String& label); 236 236 static void consoleTimeStamp(Frame&, Ref<Inspector::ScriptArguments>&&); 237 237 static void startProfiling(Page&, JSC::ExecState*, const String& title); … … 406 406 static void addMessageToConsoleImpl(InstrumentingAgents&, std::unique_ptr<Inspector::ConsoleMessage>); 407 407 408 static void consoleCountImpl(InstrumentingAgents&, JSC::ExecState*, Ref<Inspector::ScriptArguments>&&);409 static void consoleCountResetImpl(InstrumentingAgents&, JSC::ExecState*, Ref<Inspector::ScriptArguments>&&);408 static void consoleCountImpl(InstrumentingAgents&, JSC::ExecState*, const String& label); 409 static void consoleCountResetImpl(InstrumentingAgents&, JSC::ExecState*, const String& label); 410 410 static void takeHeapSnapshotImpl(InstrumentingAgents&, const String& title); 411 static void startConsoleTimingImpl(InstrumentingAgents&, Frame&, const String& title);412 static void startConsoleTimingImpl(InstrumentingAgents&, const String& title);413 static void logConsoleTimingImpl(InstrumentingAgents&, const String& title, Ref<Inspector::ScriptArguments>&&);414 static void stopConsoleTimingImpl(InstrumentingAgents&, Frame&, const String& title, Ref<Inspector::ScriptCallStack>&&);415 static void stopConsoleTimingImpl(InstrumentingAgents&, const String& title, Ref<Inspector::ScriptCallStack>&&);411 static void startConsoleTimingImpl(InstrumentingAgents&, Frame&, JSC::ExecState*, const String& label); 412 static void startConsoleTimingImpl(InstrumentingAgents&, JSC::ExecState*, const String& label); 413 static void logConsoleTimingImpl(InstrumentingAgents&, JSC::ExecState*, const String& label, Ref<Inspector::ScriptArguments>&&); 414 static void stopConsoleTimingImpl(InstrumentingAgents&, Frame&, JSC::ExecState*, const String& label); 415 static void stopConsoleTimingImpl(InstrumentingAgents&, JSC::ExecState*, const String& label); 416 416 static void consoleTimeStampImpl(InstrumentingAgents&, Frame&, Ref<Inspector::ScriptArguments>&&); 417 417 static void startProfilingImpl(InstrumentingAgents&, JSC::ExecState*, const String& title); … … 1388 1388 } 1389 1389 1390 inline void InspectorInstrumentation::consoleCount(Page& page, JSC::ExecState* state, Ref<Inspector::ScriptArguments>&& arguments)1391 { 1392 consoleCountImpl(instrumentingAgentsForPage(page), state, WTFMove(arguments));1393 } 1394 1395 inline void InspectorInstrumentation::consoleCount(WorkerGlobalScope& workerGlobalScope, JSC::ExecState* state, Ref<Inspector::ScriptArguments>&& arguments)1396 { 1397 consoleCountImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), state, WTFMove(arguments));1398 } 1399 1400 inline void InspectorInstrumentation::consoleCountReset(Page& page, JSC::ExecState* state, Ref<Inspector::ScriptArguments>&& arguments)1401 { 1402 consoleCountResetImpl(instrumentingAgentsForPage(page), state, WTFMove(arguments));1403 } 1404 1405 inline void InspectorInstrumentation::consoleCountReset(WorkerGlobalScope& workerGlobalScope, JSC::ExecState* state, Ref<Inspector::ScriptArguments>&& arguments)1406 { 1407 consoleCountResetImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), state, WTFMove(arguments));1390 inline void InspectorInstrumentation::consoleCount(Page& page, JSC::ExecState* state, const String& label) 1391 { 1392 consoleCountImpl(instrumentingAgentsForPage(page), state, label); 1393 } 1394 1395 inline void InspectorInstrumentation::consoleCount(WorkerGlobalScope& workerGlobalScope, JSC::ExecState* state, const String& label) 1396 { 1397 consoleCountImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), state, label); 1398 } 1399 1400 inline void InspectorInstrumentation::consoleCountReset(Page& page, JSC::ExecState* state, const String& label) 1401 { 1402 consoleCountResetImpl(instrumentingAgentsForPage(page), state, label); 1403 } 1404 1405 inline void InspectorInstrumentation::consoleCountReset(WorkerGlobalScope& workerGlobalScope, JSC::ExecState* state, const String& label) 1406 { 1407 consoleCountResetImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), state, label); 1408 1408 } 1409 1409 … … 1415 1415 } 1416 1416 1417 inline void InspectorInstrumentation::startConsoleTiming(Frame& frame, const String& title)1418 { 1419 if ( InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))1420 startConsoleTimingImpl(*instrumentingAgents, frame, title);1421 } 1422 1423 inline void InspectorInstrumentation::startConsoleTiming(WorkerGlobalScope& workerGlobalScope, const String& title)1424 { 1425 startConsoleTimingImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), title);1426 } 1427 1428 inline void InspectorInstrumentation::logConsoleTiming(Frame& frame, const String& title, Ref<Inspector::ScriptArguments>&& arguments)1429 { 1430 if ( InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))1431 logConsoleTimingImpl(*instrumentingAgents, title, WTFMove(arguments));1432 } 1433 1434 inline void InspectorInstrumentation::logConsoleTiming(WorkerGlobalScope& workerGlobalScope, const String& title, Ref<Inspector::ScriptArguments>&& arguments)1435 { 1436 logConsoleTimingImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), title, WTFMove(arguments));1437 } 1438 1439 inline void InspectorInstrumentation::stopConsoleTiming(Frame& frame, const String& title, Ref<Inspector::ScriptCallStack>&& stack)1440 { 1441 if ( InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))1442 stopConsoleTimingImpl(*instrumentingAgents, frame, title, WTFMove(stack));1443 } 1444 1445 inline void InspectorInstrumentation::stopConsoleTiming(WorkerGlobalScope& workerGlobalScope, const String& title, Ref<Inspector::ScriptCallStack>&& stack)1446 { 1447 stopConsoleTimingImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), title, WTFMove(stack));1417 inline void InspectorInstrumentation::startConsoleTiming(Frame& frame, JSC::ExecState* exec, const String& label) 1418 { 1419 if (auto* instrumentingAgents = instrumentingAgentsForFrame(frame)) 1420 startConsoleTimingImpl(*instrumentingAgents, frame, exec, label); 1421 } 1422 1423 inline void InspectorInstrumentation::startConsoleTiming(WorkerGlobalScope& workerGlobalScope, JSC::ExecState* exec, const String& label) 1424 { 1425 startConsoleTimingImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), exec, label); 1426 } 1427 1428 inline void InspectorInstrumentation::logConsoleTiming(Frame& frame, JSC::ExecState* exec, const String& label, Ref<Inspector::ScriptArguments>&& arguments) 1429 { 1430 if (auto* instrumentingAgents = instrumentingAgentsForFrame(frame)) 1431 logConsoleTimingImpl(*instrumentingAgents, exec, label, WTFMove(arguments)); 1432 } 1433 1434 inline void InspectorInstrumentation::logConsoleTiming(WorkerGlobalScope& workerGlobalScope, JSC::ExecState* exec, const String& label, Ref<Inspector::ScriptArguments>&& arguments) 1435 { 1436 logConsoleTimingImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), exec, label, WTFMove(arguments)); 1437 } 1438 1439 inline void InspectorInstrumentation::stopConsoleTiming(Frame& frame, JSC::ExecState* exec, const String& label) 1440 { 1441 if (auto* instrumentingAgents = instrumentingAgentsForFrame(frame)) 1442 stopConsoleTimingImpl(*instrumentingAgents, frame, exec, label); 1443 } 1444 1445 inline void InspectorInstrumentation::stopConsoleTiming(WorkerGlobalScope& workerGlobalScope, JSC::ExecState* exec, const String& label) 1446 { 1447 stopConsoleTimingImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), exec, label); 1448 1448 } 1449 1449 -
trunk/Source/WebCore/page/PageConsoleClient.cpp
r246850 r246876 171 171 } 172 172 173 void PageConsoleClient::count(JSC::ExecState* exec, Ref<ScriptArguments>&& arguments)174 { 175 InspectorInstrumentation::consoleCount(m_page, exec, WTFMove(arguments));176 } 177 178 void PageConsoleClient::countReset(JSC::ExecState* exec, Ref<ScriptArguments>&& arguments)179 { 180 InspectorInstrumentation::consoleCountReset(m_page, exec, WTFMove(arguments));173 void PageConsoleClient::count(JSC::ExecState* exec, const String& label) 174 { 175 InspectorInstrumentation::consoleCount(m_page, exec, label); 176 } 177 178 void PageConsoleClient::countReset(JSC::ExecState* exec, const String& label) 179 { 180 InspectorInstrumentation::consoleCountReset(m_page, exec, label); 181 181 } 182 182 … … 198 198 } 199 199 200 void PageConsoleClient::time(JSC::ExecState* , const String& title)201 { 202 InspectorInstrumentation::startConsoleTiming(m_page.mainFrame(), title);203 } 204 205 void PageConsoleClient::timeLog(JSC::ExecState* , const String& title, Ref<ScriptArguments>&& arguments)206 { 207 InspectorInstrumentation::logConsoleTiming(m_page.mainFrame(), title, WTFMove(arguments));208 } 209 210 void PageConsoleClient::timeEnd(JSC::ExecState* exec, const String& title)211 { 212 InspectorInstrumentation::stopConsoleTiming(m_page.mainFrame(), title, createScriptCallStackForConsole(exec, 1));200 void PageConsoleClient::time(JSC::ExecState* exec, const String& label) 201 { 202 InspectorInstrumentation::startConsoleTiming(m_page.mainFrame(), exec, label); 203 } 204 205 void PageConsoleClient::timeLog(JSC::ExecState* exec, const String& label, Ref<ScriptArguments>&& arguments) 206 { 207 InspectorInstrumentation::logConsoleTiming(m_page.mainFrame(), exec, label, WTFMove(arguments)); 208 } 209 210 void PageConsoleClient::timeEnd(JSC::ExecState* exec, const String& label) 211 { 212 InspectorInstrumentation::stopConsoleTiming(m_page.mainFrame(), exec, label); 213 213 } 214 214 -
trunk/Source/WebCore/page/PageConsoleClient.h
r246850 r246876 68 68 protected: 69 69 void messageWithTypeAndLevel(MessageType, MessageLevel, JSC::ExecState*, Ref<Inspector::ScriptArguments>&&) override; 70 void count(JSC::ExecState*, Ref<Inspector::ScriptArguments>&&) override;71 void countReset(JSC::ExecState*, Ref<Inspector::ScriptArguments>&&) override;70 void count(JSC::ExecState*, const String& label) override; 71 void countReset(JSC::ExecState*, const String& label) override; 72 72 void profile(JSC::ExecState*, const String& title) override; 73 73 void profileEnd(JSC::ExecState*, const String& title) override; 74 74 void takeHeapSnapshot(JSC::ExecState*, const String& title) override; 75 void time(JSC::ExecState*, const String& title) override;76 void timeLog(JSC::ExecState*, const String& title, Ref<Inspector::ScriptArguments>&&) override;77 void timeEnd(JSC::ExecState*, const String& title) override;75 void time(JSC::ExecState*, const String& label) override; 76 void timeLog(JSC::ExecState*, const String& label, Ref<Inspector::ScriptArguments>&&) override; 77 void timeEnd(JSC::ExecState*, const String& label) override; 78 78 void timeStamp(JSC::ExecState*, Ref<Inspector::ScriptArguments>&&) override; 79 79 void record(JSC::ExecState*, Ref<Inspector::ScriptArguments>&&) override; -
trunk/Source/WebCore/workers/WorkerConsoleClient.cpp
r246850 r246876 51 51 } 52 52 53 void WorkerConsoleClient::count(JSC::ExecState* exec, Ref<ScriptArguments>&& arguments)53 void WorkerConsoleClient::count(JSC::ExecState* exec, const String& label) 54 54 { 55 InspectorInstrumentation::consoleCount(m_workerGlobalScope, exec, WTFMove(arguments));55 InspectorInstrumentation::consoleCount(m_workerGlobalScope, exec, label); 56 56 } 57 57 58 void WorkerConsoleClient::countReset(JSC::ExecState* exec, Ref<ScriptArguments>&& arguments)58 void WorkerConsoleClient::countReset(JSC::ExecState* exec, const String& label) 59 59 { 60 InspectorInstrumentation::consoleCountReset(m_workerGlobalScope, exec, WTFMove(arguments));60 InspectorInstrumentation::consoleCountReset(m_workerGlobalScope, exec, label); 61 61 } 62 62 63 void WorkerConsoleClient::time(JSC::ExecState* , const String& title)63 void WorkerConsoleClient::time(JSC::ExecState* exec, const String& label) 64 64 { 65 InspectorInstrumentation::startConsoleTiming(m_workerGlobalScope, title);65 InspectorInstrumentation::startConsoleTiming(m_workerGlobalScope, exec, label); 66 66 } 67 67 68 void WorkerConsoleClient::timeLog(JSC::ExecState* , const String& title, Ref<ScriptArguments>&& arguments)68 void WorkerConsoleClient::timeLog(JSC::ExecState* exec, const String& label, Ref<ScriptArguments>&& arguments) 69 69 { 70 InspectorInstrumentation::logConsoleTiming(m_workerGlobalScope, title, WTFMove(arguments));70 InspectorInstrumentation::logConsoleTiming(m_workerGlobalScope, exec, label, WTFMove(arguments)); 71 71 } 72 72 73 void WorkerConsoleClient::timeEnd(JSC::ExecState* exec, const String& title)73 void WorkerConsoleClient::timeEnd(JSC::ExecState* exec, const String& label) 74 74 { 75 InspectorInstrumentation::stopConsoleTiming(m_workerGlobalScope, title, createScriptCallStackForConsole(exec, 1));75 InspectorInstrumentation::stopConsoleTiming(m_workerGlobalScope, exec, label); 76 76 } 77 77 -
trunk/Source/WebCore/workers/WorkerConsoleClient.h
r246850 r246876 44 44 protected: 45 45 void messageWithTypeAndLevel(MessageType, MessageLevel, JSC::ExecState*, Ref<Inspector::ScriptArguments>&&) override; 46 void count(JSC::ExecState*, Ref<Inspector::ScriptArguments>&&) override;47 void countReset(JSC::ExecState*, Ref<Inspector::ScriptArguments>&&) override;46 void count(JSC::ExecState*, const String& label) override; 47 void countReset(JSC::ExecState*, const String& label) override; 48 48 void profile(JSC::ExecState*, const String& title) override; 49 49 void profileEnd(JSC::ExecState*, const String& title) override; 50 50 void takeHeapSnapshot(JSC::ExecState*, const String& title) override; 51 void time(JSC::ExecState*, const String& title) override;52 void timeLog(JSC::ExecState*, const String& title, Ref<Inspector::ScriptArguments>&&) override;53 void timeEnd(JSC::ExecState*, const String& title) override;51 void time(JSC::ExecState*, const String& label) override; 52 void timeLog(JSC::ExecState*, const String& label, Ref<Inspector::ScriptArguments>&&) override; 53 void timeEnd(JSC::ExecState*, const String& label) override; 54 54 void timeStamp(JSC::ExecState*, Ref<Inspector::ScriptArguments>&&) override; 55 55 void record(JSC::ExecState*, Ref<Inspector::ScriptArguments>&&) override; -
trunk/Source/WebCore/worklets/WorkletConsoleClient.cpp
r246850 r246876 53 53 } 54 54 55 void WorkletConsoleClient::count(JSC::ExecState*, Ref<ScriptArguments>&&) { }56 void WorkletConsoleClient::countReset(JSC::ExecState*, Ref<ScriptArguments>&&) { }55 void WorkletConsoleClient::count(JSC::ExecState*, const String&) { } 56 void WorkletConsoleClient::countReset(JSC::ExecState*, const String&) { } 57 57 58 58 void WorkletConsoleClient::time(JSC::ExecState*, const String&) { } -
trunk/Source/WebCore/worklets/WorkletConsoleClient.h
r246850 r246876 46 46 private: 47 47 void messageWithTypeAndLevel(MessageType, MessageLevel, JSC::ExecState*, Ref<Inspector::ScriptArguments>&&) final; 48 void count(JSC::ExecState*, Ref<Inspector::ScriptArguments>&&) final;49 void countReset(JSC::ExecState*, Ref<Inspector::ScriptArguments>&&) final;48 void count(JSC::ExecState*, const String& label) final; 49 void countReset(JSC::ExecState*, const String& label) final; 50 50 void profile(JSC::ExecState*, const String& title) final; 51 51 void profileEnd(JSC::ExecState*, const String& title) final; 52 52 void takeHeapSnapshot(JSC::ExecState*, const String& title) final; 53 void time(JSC::ExecState*, const String& title) final;54 void timeLog(JSC::ExecState*, const String& title, Ref<Inspector::ScriptArguments>&&) final;55 void timeEnd(JSC::ExecState*, const String& title) final;53 void time(JSC::ExecState*, const String& label) final; 54 void timeLog(JSC::ExecState*, const String& label, Ref<Inspector::ScriptArguments>&&) final; 55 void timeEnd(JSC::ExecState*, const String& label) final; 56 56 void timeStamp(JSC::ExecState*, Ref<Inspector::ScriptArguments>&&) final; 57 57 void record(JSC::ExecState*, Ref<Inspector::ScriptArguments>&&) final; -
trunk/Source/WebInspectorUI/ChangeLog
r246866 r246876 1 2019-06-27 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: throw an error if console.count/console.countReset is called with an object that throws an error from toString 4 https://bugs.webkit.org/show_bug.cgi?id=199252 5 6 Reviewed by Joseph Pecoraro. 7 8 Add entries for `console.countReset` and `console.timeLog`. 9 10 Rename `title` to `label` for `console.time`, `console.timeLog`, and `console.timeEnd` to 11 better match the spec. 12 13 * UserInterface/Models/NativeFunctionParameters.js: 14 1 15 2019-06-26 Joseph Pecoraro <pecoraro@apple.com> 2 16 -
trunk/Source/WebInspectorUI/UserInterface/Models/NativeFunctionParameters.js
r242992 r246876 162 162 Console: { 163 163 assert: "condition, [message], [...values]", 164 count: "[label]", 164 count: "label = \"default\"", 165 countReset: "label = \"default\"", 165 166 debug: "message, [...values]", 166 167 dir: "object", … … 179 180 table: "data, [columns]", 180 181 takeHeapSnapshot: "[label]", 181 time: "name = \"default\"", 182 timeEnd: "name = \"default\"", 182 time: "label = \"default\"", 183 timeLog: "label = \"default\"", 184 timeEnd: "label = \"default\"", 183 185 timeStamp: "[label]", 184 186 trace: "message, [...values]",
Note: See TracChangeset
for help on using the changeset viewer.