Skip to content

Commit

Permalink
Inspector snapshot
Browse files Browse the repository at this point in the history
Blink Commit: 62cd277117e6f8ec53e31b1be58290a6f7ab42ef
  • Loading branch information
Eugene Ostroukhov committed Aug 10, 2016
1 parent fa977c8 commit e6b8355
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function push(array, var_args)
*/
function toString(obj)
{
// We don't use String(obj) because String16 could be overridden.
// We don't use String(obj) because String could be overridden.
// Also the ("" + obj) expression may throw.
try {
return "" + obj;
Expand Down Expand Up @@ -171,7 +171,8 @@ function doesAttributeHaveObservableSideEffectOnGet(object, attribute)
{
for (var interfaceName in domAttributesWithObservableSideEffectOnGet) {
var interfaceFunction = inspectedGlobalObject[interfaceName];
var isInstance = typeof interfaceFunction === "function" && object instanceof interfaceFunction;
// instanceof call looks safe after typeof check.
var isInstance = typeof interfaceFunction === "function" && /* suppressBlacklist */ object instanceof interfaceFunction;
if (isInstance)
return attribute in domAttributesWithObservableSideEffectOnGet[interfaceName];
}
Expand All @@ -198,18 +199,17 @@ InjectedScript.primitiveTypes = {
}

/**
* @type {!Map<string, string>}
* @type {!Object<string, string>}
* @const
*/
InjectedScript.closureTypes = new Map([
["local", "Local"],
["closure", "Closure"],
["catch", "Catch"],
["block", "Block"],
["script", "Script"],
["with", "With Block"],
["global", "Global"]
]);
InjectedScript.closureTypes = { __proto__: null };
InjectedScript.closureTypes["local"] = "Local";
InjectedScript.closureTypes["closure"] = "Closure";
InjectedScript.closureTypes["catch"] = "Catch";
InjectedScript.closureTypes["block"] = "Block";
InjectedScript.closureTypes["script"] = "Script";
InjectedScript.closureTypes["with"] = "With Block";
InjectedScript.closureTypes["global"] = "Global";

InjectedScript.prototype = {
/**
Expand Down Expand Up @@ -637,7 +637,8 @@ InjectedScript.prototype = {

if (isSymbol(obj)) {
try {
return obj.toString() || "Symbol";
// It isn't safe, because Symbol.prototype.toString can be overriden.
return /* suppressBlacklist */ obj.toString() || "Symbol";
} catch (e) {
return "Symbol";
}
Expand Down Expand Up @@ -668,7 +669,7 @@ InjectedScript.prototype = {
return "Scopes[" + obj.length + "]";

if (subtype === "internal#scope")
return (InjectedScript.closureTypes.get(obj.type) || "Unknown") + (obj.name ? " (" + obj.name + ")" : "");
return (InjectedScript.closureTypes[obj.type] || "Unknown") + (obj.name ? " (" + obj.name + ")" : "");

return className;
},
Expand Down Expand Up @@ -793,7 +794,8 @@ InjectedScript.RemoteObject.prototype = {
*/
function logError(error)
{
Promise.resolve().then(inspectedGlobalObject.console.error.bind(inspectedGlobalObject.console, "Custom Formatter Failed: " + error.message));
// We use user code to generate custom output for object, we can use user code for reporting error too.
Promise.resolve().then(/* suppressBlacklist */ inspectedGlobalObject.console.error.bind(inspectedGlobalObject.console, "Custom Formatter Failed: " + error.message));
}

/**
Expand Down
6 changes: 5 additions & 1 deletion third_party/v8_inspector/platform/v8_inspector/V8Compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ class V8_EXPORT MicrotasksScope {
};

} // namespace v8

#define V8_FUNCTION_NEW_REMOVE_PROTOTYPE(context, callback, data, length) \
v8::Function::New((context), (callback), (data), (length))
#else
#define V8_FUNCTION_NEW_REMOVE_PROTOTYPE(context, callback, data, length) \
v8::Function::New((context), (callback), (data), (length), v8::ConstructorBehavior::kThrow)
#endif // V8_MAJOR_VERSION < 5 || (V8_MAJOR_VERSION == 5 && V8_MINOR_VERSION < 1)

#endif // V8Compat_h
6 changes: 3 additions & 3 deletions third_party/v8_inspector/platform/v8_inspector/V8Console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,13 +271,13 @@ void createBoundFunctionProperty(v8::Local<v8::Context> context, v8::Local<v8::O
{
v8::Local<v8::String> funcName = toV8StringInternalized(context->GetIsolate(), name);
v8::Local<v8::Function> func;
if (!v8::Function::New(context, callback, console, 0, v8::ConstructorBehavior::kThrow).ToLocal(&func))
if (!V8_FUNCTION_NEW_REMOVE_PROTOTYPE(context, callback, console, 0).ToLocal(&func))
return;
func->SetName(funcName);
if (description) {
v8::Local<v8::String> returnValue = toV8String(context->GetIsolate(), description);
v8::Local<v8::Function> toStringFunction;
if (v8::Function::New(context, returnDataCallback, returnValue, 0, v8::ConstructorBehavior::kThrow).ToLocal(&toStringFunction))
if (V8_FUNCTION_NEW_REMOVE_PROTOTYPE(context, returnDataCallback, returnValue, 0).ToLocal(&toStringFunction))
func->Set(toV8StringInternalized(context->GetIsolate(), "toString"), toStringFunction);
}
if (!console->Set(context, funcName, func).FromMaybe(false))
Expand Down Expand Up @@ -690,7 +690,7 @@ v8::Local<v8::Object> V8Console::createConsole(InspectedContext* inspectedContex
DCHECK(success);

if (hasMemoryAttribute)
console->SetAccessorProperty(toV8StringInternalized(isolate, "memory"), v8::Function::New(context, V8Console::memoryGetterCallback, console, 0, v8::ConstructorBehavior::kThrow).ToLocalChecked(), v8::Function::New(context, V8Console::memorySetterCallback, v8::Local<v8::Value>(), 0, v8::ConstructorBehavior::kThrow).ToLocalChecked(), static_cast<v8::PropertyAttribute>(v8::None), v8::DEFAULT);
console->SetAccessorProperty(toV8StringInternalized(isolate, "memory"), V8_FUNCTION_NEW_REMOVE_PROTOTYPE(context, V8Console::memoryGetterCallback, console, 0).ToLocalChecked(), V8_FUNCTION_NEW_REMOVE_PROTOTYPE(context, V8Console::memorySetterCallback, v8::Local<v8::Value>(), 0).ToLocalChecked(), static_cast<v8::PropertyAttribute>(v8::None), v8::DEFAULT);

console->SetPrivate(context, inspectedContextPrivateKey(isolate), v8::External::New(isolate, inspectedContext));
return console;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ void V8Debugger::breakProgram()

v8::HandleScope scope(m_isolate);
v8::Local<v8::Function> breakFunction;
if (!v8::Function::New(m_isolate->GetCurrentContext(), &V8Debugger::breakProgramCallback, v8::External::New(m_isolate, this), 0, v8::ConstructorBehavior::kThrow).ToLocal(&breakFunction))
if (!V8_FUNCTION_NEW_REMOVE_PROTOTYPE(m_isolate->GetCurrentContext(), &V8Debugger::breakProgramCallback, v8::External::New(m_isolate, this), 0).ToLocal(&breakFunction))
return;
v8::Debug::Call(debuggerContext(), breakFunction).ToLocalChecked();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void setFunctionProperty(v8::Local<v8::Context> context, v8::Local<v8::Object> o
{
v8::Local<v8::String> funcName = toV8StringInternalized(context->GetIsolate(), name);
v8::Local<v8::Function> func;
if (!v8::Function::New(context, callback, external, 0, v8::ConstructorBehavior::kThrow).ToLocal(&func))
if (!V8_FUNCTION_NEW_REMOVE_PROTOTYPE(context, callback, external, 0).ToLocal(&func))
return;
func->SetName(funcName);
if (!obj->Set(context, funcName, func).FromMaybe(false))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "platform/v8_inspector/InjectedScript.h"
#include "platform/v8_inspector/InspectedContext.h"
#include "platform/v8_inspector/RemoteObjectId.h"
#include "platform/v8_inspector/V8Compat.h"
#include "platform/v8_inspector/V8ConsoleMessage.h"
#include "platform/v8_inspector/V8Debugger.h"
#include "platform/v8_inspector/V8DebuggerAgentImpl.h"
Expand Down Expand Up @@ -81,12 +82,12 @@ class ProtocolPromiseHandler {
ProtocolPromiseHandler<Callback>* handler = new ProtocolPromiseHandler(inspector, contextGroupId, executionContextId, objectGroup, returnByValue, generatePreview, std::move(callback));
v8::Local<v8::Value> wrapper = handler->m_wrapper.Get(inspector->isolate());

v8::Local<v8::Function> thenCallbackFunction = v8::Function::New(context, thenCallback, wrapper, 0, v8::ConstructorBehavior::kThrow).ToLocalChecked();
v8::Local<v8::Function> thenCallbackFunction = V8_FUNCTION_NEW_REMOVE_PROTOTYPE(context, thenCallback, wrapper, 0).ToLocalChecked();
if (promise->Then(context, thenCallbackFunction).IsEmpty()) {
rawCallback->sendFailure("Internal error");
return;
}
v8::Local<v8::Function> catchCallbackFunction = v8::Function::New(context, catchCallback, wrapper, 0, v8::ConstructorBehavior::kThrow).ToLocalChecked();
v8::Local<v8::Function> catchCallbackFunction = V8_FUNCTION_NEW_REMOVE_PROTOTYPE(context, catchCallback, wrapper, 0).ToLocalChecked();
if (promise->Catch(context, catchCallbackFunction).IsEmpty()) {
rawCallback->sendFailure("Internal error");
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
// found in the LICENSE file.

// This file is automatically generated. Do not modify.
#define V8_INSPECTOR_REVISION "62f9bf90d67be3a8b3c89e15a21504b767c3357d"
#define V8_INSPECTOR_REVISION "62cd277117e6f8ec53e31b1be58290a6f7ab42ef"

0 comments on commit e6b8355

Please sign in to comment.