Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(136)

Side by Side Diff: third_party/WebKit/Source/platform/v8_inspector/InjectedScript.cpp

Issue 1707043002: [DevTools] Support CommandLineAPI in snippets (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 return; 335 return;
336 RefPtr<JSONObject> object; 336 RefPtr<JSONObject> object;
337 if (!parsedObjectId->asObject(&object)) 337 if (!parsedObjectId->asObject(&object))
338 return; 338 return;
339 int boundId = 0; 339 int boundId = 0;
340 if (!object->getNumber("id", &boundId)) 340 if (!object->getNumber("id", &boundId))
341 return; 341 return;
342 m_native->unbind(boundId); 342 m_native->unbind(boundId);
343 } 343 }
344 344
345 v8::MaybeLocal<v8::Value> InjectedScript::runCompiledScript(v8::Local<v8::Script > script, bool includeCommandLineAPI)
346 {
347 v8::Local<v8::Symbol> commandLineAPISymbolValue = V8Debugger::commandLineAPI Symbol(m_isolate);
348 v8::Local<v8::Object> global = context()->Global();
349 if (includeCommandLineAPI) {
350 V8FunctionCall function(m_client, context(), v8Value(), "commandLineAPI" );
351 bool hadException = false;
352 v8::Local<v8::Value> commandLineAPI = function.call(hadException, false) ;
353 if (!hadException)
354 global->Set(commandLineAPISymbolValue, commandLineAPI->ToObject(m_is olate));
dgozman 2016/02/18 01:28:33 nit: remove ->ToObject
kozy 2016/02/18 01:55:01 Done.
355 }
356
357 v8::MaybeLocal<v8::Value> maybeValue = m_client->runCompiledScript(context() , script);
358 if (includeCommandLineAPI)
359 global->Delete(context(), commandLineAPISymbolValue);
360
361 return maybeValue;
362 }
363
345 PassRefPtr<Array<CallFrame>> InjectedScript::wrapCallFrames(v8::Local<v8::Object > callFrames, int asyncOrdinal) 364 PassRefPtr<Array<CallFrame>> InjectedScript::wrapCallFrames(v8::Local<v8::Object > callFrames, int asyncOrdinal)
346 { 365 {
347 v8::HandleScope handles(m_isolate); 366 v8::HandleScope handles(m_isolate);
348 V8FunctionCall function(m_client, context(), v8Value(), "wrapCallFrames"); 367 V8FunctionCall function(m_client, context(), v8Value(), "wrapCallFrames");
349 function.appendArgument(callFrames); 368 function.appendArgument(callFrames);
350 function.appendArgument(asyncOrdinal); 369 function.appendArgument(asyncOrdinal);
351 bool hadException = false; 370 bool hadException = false;
352 v8::Local<v8::Value> callFramesValue = callFunctionWithEvalEnabled(function, hadException); 371 v8::Local<v8::Value> callFramesValue = callFunctionWithEvalEnabled(function, hadException);
353 ASSERT(!hadException); 372 ASSERT(!hadException);
354 RefPtr<JSONValue> result = toJSONValue(context(), callFramesValue); 373 RefPtr<JSONValue> result = toJSONValue(context(), callFramesValue);
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 *result = JSONString::create(String::format("Object has too long ref erence chain(must not be longer than %d)", JSONValue::maxDepth)); 540 *result = JSONString::create(String::format("Object has too long ref erence chain(must not be longer than %d)", JSONValue::maxDepth));
522 } 541 }
523 } 542 }
524 543
525 void InjectedScript::dispose() 544 void InjectedScript::dispose()
526 { 545 {
527 m_manager->discardInjectedScript(m_contextId); 546 m_manager->discardInjectedScript(m_contextId);
528 } 547 }
529 548
530 } // namespace blink 549 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698