Diff
Modified: trunk/LayoutTests/ChangeLog (138496 => 138497)
--- trunk/LayoutTests/ChangeLog 2012-12-27 11:20:58 UTC (rev 138496)
+++ trunk/LayoutTests/ChangeLog 2012-12-27 11:48:49 UTC (rev 138497)
@@ -1,3 +1,17 @@
+2012-12-25 Andrey Adaikin <[email protected]>
+
+ Web Inspector: [Canvas] report if there is any uninstrumented canvas on a page
+ https://bugs.webkit.org/show_bug.cgi?id=105721
+
+ Reviewed by Yury Semikhatsky.
+
+ * inspector/profiler/canvas-profiler-test.js:
+ (initialize_CanvasWebGLProfilerTest.InspectorTest.enableCanvasAgent):
+ (initialize_CanvasWebGLProfilerTest.InspectorTest.disableCanvasAgent):
+ (initialize_CanvasWebGLProfilerTest):
+ * inspector/profiler/canvas2d/canvas-has-uninstrumented-canvases-expected.txt: Added.
+ * inspector/profiler/canvas2d/canvas-has-uninstrumented-canvases.html: Added.
+
2012-12-27 Vsevolod Vlasov <[email protected]>
Web Inspector: Simplify script mappings by introducing DefaultScriptMapping.
Modified: trunk/LayoutTests/inspector/profiler/canvas-profiler-test.js (138496 => 138497)
--- trunk/LayoutTests/inspector/profiler/canvas-profiler-test.js 2012-12-27 11:20:58 UTC (rev 138496)
+++ trunk/LayoutTests/inspector/profiler/canvas-profiler-test.js 2012-12-27 11:48:49 UTC (rev 138497)
@@ -14,13 +14,32 @@
try {
CanvasAgent.enable(canvasAgentEnabled);
} catch (e) {
- InspectorTest.addResult("Exception while enabling CanvasAgent", e);
+ InspectorTest.addResult("Exception while enabling CanvasAgent: " + e);
InspectorTest.completeTest();
}
};
+InspectorTest.disableCanvasAgent = function(callback)
+{
+ function canvasAgentDisabled(error)
+ {
+ if (!error)
+ InspectorTest.safeWrap(callback)();
+ else {
+ InspectorTest.addResult("FAILED to disable CanvasAgent: " + error);
+ InspectorTest.completeTest();
+ }
+ }
+ try {
+ CanvasAgent.disable(canvasAgentDisabled);
+ } catch (e) {
+ InspectorTest.addResult("Exception while disabling CanvasAgent: " + e);
+ InspectorTest.completeTest();
+ }
};
+};
+
function createWebGLContext(opt_canvas)
{
if (window.testRunner)
Added: trunk/LayoutTests/inspector/profiler/canvas2d/canvas-has-uninstrumented-canvases-expected.txt (0 => 138497)
--- trunk/LayoutTests/inspector/profiler/canvas2d/canvas-has-uninstrumented-canvases-expected.txt (rev 0)
+++ trunk/LayoutTests/inspector/profiler/canvas2d/canvas-has-uninstrumented-canvases-expected.txt 2012-12-27 11:48:49 UTC (rev 138497)
@@ -0,0 +1,6 @@
+Tests Canvas hasUninstrumentedCanvases protocol method.
+
+Bug 105721
+hasUninstrumentedCanvases: false
+hasUninstrumentedCanvases: true
+
Added: trunk/LayoutTests/inspector/profiler/canvas2d/canvas-has-uninstrumented-canvases.html (0 => 138497)
--- trunk/LayoutTests/inspector/profiler/canvas2d/canvas-has-uninstrumented-canvases.html (rev 0)
+++ trunk/LayoutTests/inspector/profiler/canvas2d/canvas-has-uninstrumented-canvases.html 2012-12-27 11:48:49 UTC (rev 138497)
@@ -0,0 +1,69 @@
+<html>
+<head>
+ <script src=""
+ <script src=""
+<script>
+
+var canvas;
+
+function createCanvasElement()
+{
+ canvas = document.createElement("canvas");
+ console.assert(canvas, "Failed to create a canvas element");
+}
+
+function getCanvasContext()
+{
+ var context = canvas.getContext("2d");
+ console.assert(context, "Failed to create a canvas context");
+}
+
+function test()
+{
+ InspectorTest.evaluateInConsole("createCanvasElement()", step1);
+ function step1()
+ {
+ InspectorTest.enableCanvasAgent(step2);
+ }
+ function step2()
+ {
+ CanvasAgent.hasUninstrumentedCanvases(hasUninstrumentedCanvasesCallback1);
+ }
+ function hasUninstrumentedCanvasesCallback1(error, result)
+ {
+ InspectorTest.addResult("hasUninstrumentedCanvases: " + result);
+ InspectorTest.assertTrue(!error, "Unexpected error");
+ InspectorTest.assertEquals(false, result, "There should be no uninstrumented canvases");
+ InspectorTest.disableCanvasAgent(step3);
+ }
+ function step3()
+ {
+ InspectorTest.evaluateInConsole("getCanvasContext()", step4);
+ }
+ function step4()
+ {
+ InspectorTest.enableCanvasAgent(step5);
+ }
+ function step5()
+ {
+ CanvasAgent.hasUninstrumentedCanvases(hasUninstrumentedCanvasesCallback2);
+ }
+ function hasUninstrumentedCanvasesCallback2(error, result)
+ {
+ InspectorTest.addResult("hasUninstrumentedCanvases: " + result);
+ InspectorTest.assertTrue(!error, "Unexpected error");
+ InspectorTest.assertEquals(true, result, "There is an uninstrumented canvas!");
+ InspectorTest.completeTest();
+ }
+}
+
+</script>
+</head>
+<body _onload_="runTest()">
+<p>
+Tests Canvas hasUninstrumentedCanvases protocol method.
+</p>
+<a href="" 105721</a>
+
+</body>
+</html>
Modified: trunk/LayoutTests/platform/efl/TestExpectations (138496 => 138497)
--- trunk/LayoutTests/platform/efl/TestExpectations 2012-12-27 11:20:58 UTC (rev 138496)
+++ trunk/LayoutTests/platform/efl/TestExpectations 2012-12-27 11:48:49 UTC (rev 138497)
@@ -1567,6 +1567,7 @@
# New inspector/profiler/memory-instrumentation-canvas.html fails on JSC platforms
webkit.org/b/99001 inspector/profiler/memory-instrumentation-canvas.html
+webkit.org/b/73936 inspector/profiler/canvas2d/canvas-has-uninstrumented-canvases.html
# EFL port does not support Emacs commands.
Bug(EFL) editing/pasteboard/emacs-cntl-y-001.html [ Missing ]
Modified: trunk/LayoutTests/platform/gtk/TestExpectations (138496 => 138497)
--- trunk/LayoutTests/platform/gtk/TestExpectations 2012-12-27 11:20:58 UTC (rev 138496)
+++ trunk/LayoutTests/platform/gtk/TestExpectations 2012-12-27 11:48:49 UTC (rev 138497)
@@ -981,6 +981,7 @@
webkit.org/b/50485 inspector/profiler/heap-snapshot-summary-sorting-instances.html [ Failure ]
webkit.org/b/99001 inspector/profiler/memory-instrumentation-canvas.html [ Failure ]
webkit.org/b/50485 inspector-protocol/take-heap-snapshot.html [ Skip ]
+webkit.org/b/73936 inspector/profiler/canvas2d/canvas-has-uninstrumented-canvases.html [ Failure ]
webkit.org/b/37613 webkit.org/b/20011 printing [ Skip ]
webkit.org/b/37613 editing/execCommand/print.html [ Skip ]
Modified: trunk/LayoutTests/platform/mac/TestExpectations (138496 => 138497)
--- trunk/LayoutTests/platform/mac/TestExpectations 2012-12-27 11:20:58 UTC (rev 138496)
+++ trunk/LayoutTests/platform/mac/TestExpectations 2012-12-27 11:48:49 UTC (rev 138497)
@@ -259,6 +259,7 @@
# New inspector/profiler/memory-instrumentation-canvas.html fails on JSC platforms
webkit.org/b/99001 inspector/profiler/memory-instrumentation-canvas.html
+webkit.org/b/73936 inspector/profiler/canvas2d/canvas-has-uninstrumented-canvases.html
# Skipping newly added tests while I'm finding out what is wrong.
# https://bugs.webkit.org/show_bug.cgi?id=59706
Modified: trunk/LayoutTests/platform/win/TestExpectations (138496 => 138497)
--- trunk/LayoutTests/platform/win/TestExpectations 2012-12-27 11:20:58 UTC (rev 138496)
+++ trunk/LayoutTests/platform/win/TestExpectations 2012-12-27 11:48:49 UTC (rev 138497)
@@ -1290,6 +1290,7 @@
# New inspector/profiler/memory-instrumentation-canvas.html fails on JSC platforms
webkit.org/b/99001 inspector/profiler/memory-instrumentation-canvas.html
+webkit.org/b/73936 inspector/profiler/canvas2d/canvas-has-uninstrumented-canvases.html
# https://bugs.webkit.org/show_bug.cgi?id=40300
inspector/debugger/live-edit.html
Modified: trunk/Source/WebCore/ChangeLog (138496 => 138497)
--- trunk/Source/WebCore/ChangeLog 2012-12-27 11:20:58 UTC (rev 138496)
+++ trunk/Source/WebCore/ChangeLog 2012-12-27 11:48:49 UTC (rev 138497)
@@ -1,3 +1,38 @@
+2012-12-25 Andrey Adaikin <[email protected]>
+
+ Web Inspector: [Canvas] report if there is any uninstrumented canvas on a page
+ https://bugs.webkit.org/show_bug.cgi?id=105721
+
+ Reviewed by Yury Semikhatsky.
+
+ Adding a method to the protocol to report if there is any uninstrumented canvas on a page.
+
+ Test: inspector/profiler/canvas2d/canvas-has-uninstrumented-canvases.html
+
+ * inspector/InjectedScriptCanvasModuleSource.js:
+ (.):
+ * inspector/Inspector.json:
+ * inspector/InspectorCanvasAgent.cpp:
+ (WebCore::InspectorCanvasAgent::InspectorCanvasAgent):
+ (WebCore::InspectorCanvasAgent::enable):
+ (WebCore::InspectorCanvasAgent::disable):
+ (WebCore::InspectorCanvasAgent::hasUninstrumentedCanvases):
+ (WebCore):
+ (WebCore::InspectorCanvasAgent::captureFrame):
+ (WebCore::InspectorCanvasAgent::startCapturing):
+ (WebCore::InspectorCanvasAgent::stopCapturing):
+ (WebCore::InspectorCanvasAgent::getTraceLog):
+ (WebCore::InspectorCanvasAgent::replayTraceLog):
+ (WebCore::InspectorCanvasAgent::ensureHasUninstrumentedCanvasesCalculated):
+ (WebCore::InspectorCanvasAgent::checkIsEnabled):
+ (WebCore::InspectorCanvasAgent::reset):
+ * inspector/InspectorCanvasAgent.h:
+ (WebCore):
+ (InspectorCanvasAgent):
+ * inspector/InspectorInstrumentation.cpp:
+ (WebCore):
+ (WebCore::InspectorInstrumentation::didCommitLoadImpl):
+
2012-12-27 Vsevolod Vlasov <[email protected]>
Web Inspector: Simplify script mappings by introducing DefaultScriptMapping.
Modified: trunk/Source/WebCore/inspector/InjectedScriptCanvasModuleSource.js (138496 => 138497)
--- trunk/Source/WebCore/inspector/InjectedScriptCanvasModuleSource.js 2012-12-27 11:20:58 UTC (rev 138496)
+++ trunk/Source/WebCore/inspector/InjectedScriptCanvasModuleSource.js 2012-12-27 11:48:49 UTC (rev 138497)
@@ -1015,7 +1015,15 @@
ReplayableResource.prototype = {
/**
- * @param {Cache} cache
+ * @return {number}
+ */
+ id: function()
+ {
+ return this._data.id;
+ },
+
+ /**
+ * @param {!Cache} cache
* @return {!Resource}
*/
replay: function(cache)
@@ -1029,7 +1037,7 @@
/**
* @param {ReplayableResource|*} obj
- * @param {Cache} cache
+ * @param {!Cache} cache
* @return {*}
*/
ReplayableResource.replay = function(obj, cache)
@@ -2824,6 +2832,7 @@
var stackTrace = call.stackTrace();
var callFrame = stackTrace ? stackTrace.callFrame(0) || {} : {};
var traceLogItem = {
+ contextId: this._makeContextId(call.resource().id()),
sourceURL: callFrame.sourceURL,
lineNumber: callFrame.lineNumber,
columnNumber: callFrame.columnNumber
@@ -2881,6 +2890,15 @@
return "{\"injectedScriptId\":" + injectedScriptId + ",\"traceLogId\":" + (++this._lastTraceLogId) + "}";
},
+ /**
+ * @param {number} resourceId
+ * @return {string}
+ */
+ _makeContextId: function(resourceId)
+ {
+ return "{\"injectedScriptId\":" + injectedScriptId + ",\"canvasContextId\":" + resourceId + "}";
+ },
+
_onTraceLogPlayerReset: function()
{
this._replayContexts = [];
Modified: trunk/Source/WebCore/inspector/Inspector.json (138496 => 138497)
--- trunk/Source/WebCore/inspector/Inspector.json 2012-12-27 11:20:58 UTC (rev 138496)
+++ trunk/Source/WebCore/inspector/Inspector.json 2012-12-27 11:48:49 UTC (rev 138497)
@@ -3189,14 +3189,15 @@
"hidden": true,
"types": [
{
- "id": "TraceLogId",
+ "id": "ContextId",
"type": "string",
- "description": "Unique object identifier."
+ "description": "Unique context identifier."
},
{
"id": "Call",
"type": "object",
"properties": [
+ { "name": "contextId", "$ref": "ContextId" },
{ "name": "functionName", "type": "string", "optional": true },
{ "name": "arguments", "type": "array", "items": { "type": "string" }, "optional": true },
{ "name": "property", "type": "string", "optional": true },
@@ -3208,6 +3209,11 @@
]
},
{
+ "id": "TraceLogId",
+ "type": "string",
+ "description": "Unique trace log identifier."
+ },
+ {
"id": "TraceLog",
"type": "object",
"properties": [
@@ -3234,6 +3240,13 @@
]
},
{
+ "name": "hasUninstrumentedCanvases",
+ "returns": [
+ { "name": "result", "type": "boolean" }
+ ],
+ "description": "Checks if there is any uninstrumented canvas in the inspected page."
+ },
+ {
"name": "captureFrame",
"returns": [
{ "name": "traceLogId", "$ref": "TraceLogId" }
Modified: trunk/Source/WebCore/inspector/InspectorCanvasAgent.cpp (138496 => 138497)
--- trunk/Source/WebCore/inspector/InspectorCanvasAgent.cpp 2012-12-27 11:20:58 UTC (rev 138496)
+++ trunk/Source/WebCore/inspector/InspectorCanvasAgent.cpp 2012-12-27 11:48:49 UTC (rev 138497)
@@ -34,6 +34,10 @@
#include "InspectorCanvasAgent.h"
+#include "BindingVisitors.h"
+#include "Frame.h"
+#include "HTMLCanvasElement.h"
+#include "HTMLNames.h"
#include "InjectedScript.h"
#include "InjectedScriptCanvasModule.h"
#include "InjectedScriptManager.h"
@@ -42,6 +46,7 @@
#include "InstrumentingAgents.h"
#include "Page.h"
#include "ScriptObject.h"
+#include "ScriptProfiler.h"
#include "ScriptState.h"
namespace WebCore {
@@ -55,6 +60,7 @@
, m_inspectedPage(page)
, m_injectedScriptManager(injectedScriptManager)
, m_frontend(0)
+ , m_enabled(false)
{
}
@@ -84,14 +90,20 @@
void InspectorCanvasAgent::enable(ErrorString*)
{
- m_state->setBoolean(CanvasAgentState::canvasAgentEnabled, true);
+ if (m_enabled)
+ return;
+ m_enabled = true;
+ m_state->setBoolean(CanvasAgentState::canvasAgentEnabled, m_enabled);
m_instrumentingAgents->setInspectorCanvasAgent(this);
+ findFramesWithUninstrumentedCanvases();
}
void InspectorCanvasAgent::disable(ErrorString*)
{
+ m_enabled = false;
+ m_state->setBoolean(CanvasAgentState::canvasAgentEnabled, m_enabled);
m_instrumentingAgents->setInspectorCanvasAgent(0);
- m_state->setBoolean(CanvasAgentState::canvasAgentEnabled, false);
+ m_framesWithUninstrumentedCanvases.clear();
}
void InspectorCanvasAgent::dropTraceLog(ErrorString* errorString, const String& traceLogId)
@@ -101,8 +113,17 @@
module.dropTraceLog(errorString, traceLogId);
}
+void InspectorCanvasAgent::hasUninstrumentedCanvases(ErrorString* errorString, bool* result)
+{
+ if (!checkIsEnabled(errorString))
+ return;
+ *result = m_framesWithUninstrumentedCanvases.contains(m_inspectedPage->mainFrame());
+}
+
void InspectorCanvasAgent::captureFrame(ErrorString* errorString, String* traceLogId)
{
+ if (!checkIsEnabled(errorString))
+ return;
ScriptState* scriptState = mainWorldScriptState(m_inspectedPage->mainFrame());
InjectedScriptCanvasModule module = InjectedScriptCanvasModule::moduleForState(m_injectedScriptManager, scriptState);
if (module.hasNoValue()) {
@@ -114,6 +135,8 @@
void InspectorCanvasAgent::startCapturing(ErrorString* errorString, String* traceLogId)
{
+ if (!checkIsEnabled(errorString))
+ return;
ScriptState* scriptState = mainWorldScriptState(m_inspectedPage->mainFrame());
InjectedScriptCanvasModule module = InjectedScriptCanvasModule::moduleForState(m_injectedScriptManager, scriptState);
if (module.hasNoValue()) {
@@ -125,6 +148,8 @@
void InspectorCanvasAgent::stopCapturing(ErrorString* errorString, const String& traceLogId)
{
+ if (!checkIsEnabled(errorString))
+ return;
InjectedScriptCanvasModule module = injectedScriptCanvasModuleForTraceLogId(errorString, traceLogId);
if (!module.hasNoValue())
module.stopCapturing(errorString, traceLogId);
@@ -132,6 +157,8 @@
void InspectorCanvasAgent::getTraceLog(ErrorString* errorString, const String& traceLogId, const int* startOffset, RefPtr<TypeBuilder::Canvas::TraceLog>& traceLog)
{
+ if (!checkIsEnabled(errorString))
+ return;
InjectedScriptCanvasModule module = injectedScriptCanvasModuleForTraceLogId(errorString, traceLogId);
if (!module.hasNoValue())
module.traceLog(errorString, traceLogId, startOffset, &traceLog);
@@ -139,6 +166,8 @@
void InspectorCanvasAgent::replayTraceLog(ErrorString* errorString, const String& traceLogId, int stepNo, String* result)
{
+ if (!checkIsEnabled(errorString))
+ return;
InjectedScriptCanvasModule module = injectedScriptCanvasModuleForTraceLogId(errorString, traceLogId);
if (!module.hasNoValue())
module.replayTraceLog(errorString, traceLogId, stepNo, result);
@@ -190,6 +219,53 @@
return module;
}
+void InspectorCanvasAgent::findFramesWithUninstrumentedCanvases()
+{
+ class NodeVisitor : public WrappedNodeVisitor {
+ public:
+ NodeVisitor(Page* page, FramesWithUninstrumentedCanvases& hasUninstrumentedCanvasesResults)
+ : m_page(page)
+ , m_framesWithUninstrumentedCanvases(hasUninstrumentedCanvasesResults)
+ {
+ }
+
+ virtual void visitNode(Node* node) OVERRIDE
+ {
+ if (!node->hasTagName(HTMLNames::canvasTag) || !node->document() || !node->document()->frame())
+ return;
+
+ Frame* frame = node->document()->frame();
+ if (frame->page() != m_page)
+ return;
+
+ HTMLCanvasElement* canvas = static_cast<HTMLCanvasElement*>(node);
+ if (canvas->renderingContext())
+ m_framesWithUninstrumentedCanvases.add(frame);
+ }
+
+ private:
+ Page* m_page;
+ FramesWithUninstrumentedCanvases& m_framesWithUninstrumentedCanvases;
+ } nodeVisitor(m_inspectedPage, m_framesWithUninstrumentedCanvases);
+
+ ScriptProfiler::visitNodeWrappers(&nodeVisitor);
+}
+
+bool InspectorCanvasAgent::checkIsEnabled(ErrorString* errorString) const
+{
+ if (m_enabled)
+ return true;
+ *errorString = "Canvas agent is not enabled";
+ return false;
+}
+
+void InspectorCanvasAgent::reset()
+{
+ m_framesWithUninstrumentedCanvases.clear();
+ if (m_enabled)
+ findFramesWithUninstrumentedCanvases();
+}
+
} // namespace WebCore
#endif // ENABLE(INSPECTOR)
Modified: trunk/Source/WebCore/inspector/InspectorCanvasAgent.h (138496 => 138497)
--- trunk/Source/WebCore/inspector/InspectorCanvasAgent.h 2012-12-27 11:20:58 UTC (rev 138496)
+++ trunk/Source/WebCore/inspector/InspectorCanvasAgent.h 2012-12-27 11:48:49 UTC (rev 138497)
@@ -37,12 +37,14 @@
#include "InspectorFrontend.h"
#include "InspectorTypeBuilder.h"
#include "ScriptState.h"
+#include <wtf/HashSet.h>
#include <wtf/PassOwnPtr.h>
#include <wtf/PassRefPtr.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
+class Frame;
class InjectedScriptCanvasModule;
class InjectedScriptManager;
class InspectorState;
@@ -64,6 +66,9 @@
virtual void clearFrontend();
virtual void restore();
+ // Called from InspectorInstrumentation
+ void reset();
+
// Called from InspectorCanvasInstrumentation
ScriptObject wrapCanvas2DRenderingContextForInstrumentation(const ScriptObject&);
#if ENABLE(WEBGL)
@@ -74,6 +79,7 @@
virtual void enable(ErrorString*);
virtual void disable(ErrorString*);
virtual void dropTraceLog(ErrorString*, const String&);
+ virtual void hasUninstrumentedCanvases(ErrorString*, bool*);
virtual void captureFrame(ErrorString*, String*);
virtual void startCapturing(ErrorString*, String*);
virtual void stopCapturing(ErrorString*, const String&);
@@ -84,10 +90,15 @@
InspectorCanvasAgent(InstrumentingAgents*, InspectorCompositeState*, Page*, InjectedScriptManager*);
InjectedScriptCanvasModule injectedScriptCanvasModuleForTraceLogId(ErrorString*, const String&);
+ void findFramesWithUninstrumentedCanvases();
+ bool checkIsEnabled(ErrorString*) const;
Page* m_inspectedPage;
InjectedScriptManager* m_injectedScriptManager;
InspectorFrontend::Canvas* m_frontend;
+ bool m_enabled;
+ typedef HashSet<Frame*> FramesWithUninstrumentedCanvases;
+ FramesWithUninstrumentedCanvases m_framesWithUninstrumentedCanvases;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp (138496 => 138497)
--- trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp 2012-12-27 11:20:58 UTC (rev 138496)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp 2012-12-27 11:48:49 UTC (rev 138497)
@@ -913,6 +913,8 @@
if (InspectorLayerTreeAgent* layerTreeAgent = instrumentingAgents->inspectorLayerTreeAgent())
layerTreeAgent->reset();
#endif
+ if (InspectorCanvasAgent* canvasAgent = instrumentingAgents->inspectorCanvasAgent())
+ canvasAgent->reset();
inspectorAgent->didCommitLoad();
}
if (InspectorPageAgent* pageAgent = instrumentingAgents->inspectorPageAgent())