Commit 6c932f80 authored by kozyatinskiy's avatar kozyatinskiy Committed by Commit bot

[DevTools] Improve MainThreadDebugger::memoryInfo

Use context->Global() instead of CreationContext in MainThreadDebugger::memoryInfo.

BUG=616225
R=adamk@chromium.org,dgozman@chromium.org

Review-Url: https://codereview.chromium.org/2034203002
Cr-Commit-Position: refs/heads/master@{#397887}
parent 33490baa
<html>
<body>Iframe content.</body>
<div id="mydiv">div from iframe</div>
</html>
CONSOLE MESSAGE: line 15: div from page
Tests that console.memory works correct.
div from page
=== Dump console message ===
div from page
<html>
<head>
<script type="text/javascript" src="../../http/tests/inspector-protocol/inspector-protocol-test.js"></script>
<script>
function dumpInnerHtml()
{
frame = document.documentElement.appendChild(document.createElement("iframe"));
frame.src = "resources/iframe.html";
frame.onload = function()
{
var location = frame.contentWindow.location;
frame.remove();
memory = console.__lookupGetter__("memory").call(location);
console.log(memory.constructor.constructor("return document.querySelector(\"#mydiv\").textContent")());
}
}
function test()
{
InspectorTest.sendCommandOrDie("Console.enable", {});
InspectorTest.eventHandler["Console.messageAdded"] = dumpMessageAndCompleTest;
InspectorTest.sendCommand("Runtime.evaluate", { "expression": "dumpInnerHtml()" });
function dumpMessageAndCompleTest(result)
{
InspectorTest.log("=== Dump console message ===");
InspectorTest.log(result.params.message.text);
InspectorTest.completeTest();
}
}
</script>
</head>
<body onLoad="runTest();">Tests that console.memory works correct.</body>
<div id="mydiv">div from page</div>
</html>
......@@ -229,12 +229,12 @@ void MainThreadDebugger::reportMessageToConsole(v8::Local<v8::Context> context,
frame->console().addMessage(consoleMessage);
}
v8::MaybeLocal<v8::Value> MainThreadDebugger::memoryInfo(v8::Isolate* isolate, v8::Local<v8::Context> context, v8::Local<v8::Object> creationContext)
v8::MaybeLocal<v8::Value> MainThreadDebugger::memoryInfo(v8::Isolate* isolate, v8::Local<v8::Context> context)
{
ExecutionContext* executionContext = toExecutionContext(context);
ASSERT_UNUSED(executionContext, executionContext);
ASSERT(executionContext->isDocument());
return toV8(MemoryInfo::create(), creationContext, isolate);
return toV8(MemoryInfo::create(), context->Global(), isolate);
}
bool MainThreadDebugger::isCommandLineAPIMethod(const String& name)
......
......@@ -71,7 +71,7 @@ public:
static bool isCommandLineAPIMethod(const String& name);
void installAdditionalCommandLineAPI(v8::Local<v8::Context>, v8::Local<v8::Object>) override;
v8::MaybeLocal<v8::Value> memoryInfo(v8::Isolate*, v8::Local<v8::Context>, v8::Local<v8::Object> creationContext) override;
v8::MaybeLocal<v8::Value> memoryInfo(v8::Isolate*, v8::Local<v8::Context>) override;
protected:
void reportMessageToConsole(v8::Local<v8::Context>, ConsoleMessage*) override;
......
......@@ -106,7 +106,7 @@ void WorkerThreadDebugger::reportMessageToConsole(v8::Local<v8::Context> context
executionContext->addConsoleMessage(message);
}
v8::MaybeLocal<v8::Value> WorkerThreadDebugger::memoryInfo(v8::Isolate*, v8::Local<v8::Context>, v8::Local<v8::Object>)
v8::MaybeLocal<v8::Value> WorkerThreadDebugger::memoryInfo(v8::Isolate*, v8::Local<v8::Context>)
{
ASSERT_NOT_REACHED();
return v8::MaybeLocal<v8::Value>();
......
......@@ -59,7 +59,7 @@ public:
bool callingContextCanAccessContext(v8::Local<v8::Context> calling, v8::Local<v8::Context> target) override;
int ensureDefaultContextInGroup(int contextGroupId) override;
v8::MaybeLocal<v8::Value> memoryInfo(v8::Isolate*, v8::Local<v8::Context>, v8::Local<v8::Object>) override;
v8::MaybeLocal<v8::Value> memoryInfo(v8::Isolate*, v8::Local<v8::Context>) override;
protected:
void reportMessageToConsole(v8::Local<v8::Context>, ConsoleMessage*);
......
......@@ -448,7 +448,7 @@ void V8Console::memoryGetterCallback(const v8::FunctionCallbackInfo<v8::Value>&
{
if (V8DebuggerClient* client = ConsoleHelper(info).ensureDebuggerClient()) {
v8::Local<v8::Value> memoryValue;
if (!client->memoryInfo(info.GetIsolate(), info.GetIsolate()->GetCurrentContext(), info.Holder()).ToLocal(&memoryValue))
if (!client->memoryInfo(info.GetIsolate(), info.GetIsolate()->GetCurrentContext()).ToLocal(&memoryValue))
return;
info.GetReturnValue().Set(memoryValue);
}
......
......@@ -40,7 +40,7 @@ public:
virtual void consoleTimeEnd(const String16& title) = 0;
virtual void consoleTimeStamp(const String16& title) = 0;
virtual v8::MaybeLocal<v8::Value> memoryInfo(v8::Isolate*, v8::Local<v8::Context>, v8::Local<v8::Object> creationContext) = 0;
virtual v8::MaybeLocal<v8::Value> memoryInfo(v8::Isolate*, v8::Local<v8::Context>) = 0;
typedef void (*TimerCallback)(void*);
virtual void startRepeatingTimer(double, TimerCallback, void* data) = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment