Diff
Modified: trunk/LayoutTests/ChangeLog (219149 => 219150)
--- trunk/LayoutTests/ChangeLog 2017-07-05 20:10:19 UTC (rev 219149)
+++ trunk/LayoutTests/ChangeLog 2017-07-05 20:13:56 UTC (rev 219150)
@@ -1,3 +1,23 @@
+2017-07-05 Devin Rousso <drou...@apple.com>
+
+ Web Inspector: Allow users to log any tracked canvas context
+ https://bugs.webkit.org/show_bug.cgi?id=173397
+ <rdar://problem/33111581>
+
+ Reviewed by Joseph Pecoraro.
+
+ * inspector/canvas/resolveCanvasContext-2d-expected.txt: Added.
+ * inspector/canvas/resolveCanvasContext-2d.html: Added.
+ * inspector/canvas/resolveCanvasContext-webgl-expected.txt: Added.
+ * inspector/canvas/resolveCanvasContext-webgl.html: Added.
+ * inspector/canvas/resolveCanvasContext-webgl2-expected.txt: Added.
+ * inspector/canvas/resolveCanvasContext-webgl2.html: Added.
+ * inspector/canvas/resolveCanvasContext-webgpu-expected.txt: Added.
+ * inspector/canvas/resolveCanvasContext-webgpu.html: Added.
+ * platform/gtk/TestExpectations:
+ * platform/ios/TestExpectations:
+ * platform/win/TestExpectations:
+
2017-07-05 Antti Koivisto <an...@apple.com>
Low memory notification shouldn't cause style recalc
Added: trunk/LayoutTests/inspector/canvas/resolveCanvasContext-2d-expected.txt (0 => 219150)
--- trunk/LayoutTests/inspector/canvas/resolveCanvasContext-2d-expected.txt (rev 0)
+++ trunk/LayoutTests/inspector/canvas/resolveCanvasContext-2d-expected.txt 2017-07-05 20:13:56 UTC (rev 219150)
@@ -0,0 +1,12 @@
+Tests for the Canvas.resolveCanvasContext command for 2D contexts.
+
+
+== Running test suite: Canvas.resolveCanvasContext2D
+-- Running test case: Canvas.resolveCanvasContext2D.validIdentifier
+PASS: Payload should have type "object".
+PASS: Payload should have className "CanvasRenderingContext2D".
+
+-- Running test case: Canvas.resolveCanvasContext.invalidIdentifier
+PASS: Should produce an error.
+Error: Invalid canvas identifier
+
Added: trunk/LayoutTests/inspector/canvas/resolveCanvasContext-2d.html (0 => 219150)
--- trunk/LayoutTests/inspector/canvas/resolveCanvasContext-2d.html (rev 0)
+++ trunk/LayoutTests/inspector/canvas/resolveCanvasContext-2d.html 2017-07-05 20:13:56 UTC (rev 219150)
@@ -0,0 +1,59 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script>
+function load() {
+ window.context2d = document.body.appendChild(document.createElement("canvas")).getContext("2d");
+
+ runTest();
+}
+
+function test()
+{
+ let suite = InspectorTest.createAsyncSuite("Canvas.resolveCanvasContext2D");
+
+ suite.addTestCase({
+ name: `Canvas.resolveCanvasContext2D.validIdentifier`,
+ description: "Should return a valid object for the given canvas identifier.",
+ test(resolve, reject) {
+ let canvas = WebInspector.canvasManager.canvases.find((canvas) => canvas.contextType === WebInspector.Canvas.ContextType.Canvas2D);
+ if (!canvas) {
+ reject(`Missing Canvas.`);
+ return;
+ }
+
+ const objectGroup = "test";
+ CanvasAgent.resolveCanvasContext(canvas.identifier, objectGroup)
+ .then(({object}) => {
+ InspectorTest.expectEqual(object.type, "object", `Payload should have type "object".`);
+ InspectorTest.expectEqual(object.className, "CanvasRenderingContext2D", `Payload should have className "CanvasRenderingContext2D".`);
+ })
+ .then(resolve, reject);
+ }
+ });
+
+ // ------
+
+ suite.addTestCase({
+ name: "Canvas.resolveCanvasContext.invalidIdentifier",
+ description: "Invalid canvas identifiers should cause an error.",
+ test(resolve, reject) {
+ const identifier = "DOES_NOT_EXIST";
+ const objectGroup = "test";
+ CanvasAgent.resolveCanvasContext(identifier, objectGroup, (error) => {
+ InspectorTest.expectThat(error, "Should produce an error.");
+ InspectorTest.log("Error: " + error);
+ resolve();
+ });
+ }
+ });
+
+ suite.runTestCasesAndFinish();
+}
+</script>
+</head>
+<body _onload_="load()">
+ <p>Tests for the Canvas.resolveCanvasContext command for 2D contexts.</p>
+</body>
+</html>
Added: trunk/LayoutTests/inspector/canvas/resolveCanvasContext-webgl-expected.txt (0 => 219150)
--- trunk/LayoutTests/inspector/canvas/resolveCanvasContext-webgl-expected.txt (rev 0)
+++ trunk/LayoutTests/inspector/canvas/resolveCanvasContext-webgl-expected.txt 2017-07-05 20:13:56 UTC (rev 219150)
@@ -0,0 +1,8 @@
+Tests for the Canvas.resolveCanvasContext command for WebGL contexts.
+
+
+== Running test suite: Canvas.resolveCanvasContextWebGL
+-- Running test case: Canvas.resolveCanvasContextWebGL.validIdentifier
+PASS: Payload should have type "object".
+PASS: Payload should have className "WebGLRenderingContext".
+
Added: trunk/LayoutTests/inspector/canvas/resolveCanvasContext-webgl.html (0 => 219150)
--- trunk/LayoutTests/inspector/canvas/resolveCanvasContext-webgl.html (rev 0)
+++ trunk/LayoutTests/inspector/canvas/resolveCanvasContext-webgl.html 2017-07-05 20:13:56 UTC (rev 219150)
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script>
+function load() {
+ window.contextWebGL = document.body.appendChild(document.createElement("canvas")).getContext("webgl");
+
+ runTest();
+}
+
+function test()
+{
+ let suite = InspectorTest.createAsyncSuite("Canvas.resolveCanvasContextWebGL");
+
+ suite.addTestCase({
+ name: `Canvas.resolveCanvasContextWebGL.validIdentifier`,
+ description: "Should return a valid object for the given canvas identifier.",
+ test(resolve, reject) {
+ let canvas = WebInspector.canvasManager.canvases.find((canvas) => canvas.contextType === WebInspector.Canvas.ContextType.WebGL);
+ if (!canvas) {
+ reject(`Missing Canvas.`);
+ return;
+ }
+
+ const objectGroup = "test";
+ CanvasAgent.resolveCanvasContext(canvas.identifier, objectGroup)
+ .then(({object}) => {
+ InspectorTest.expectEqual(object.type, "object", `Payload should have type "object".`);
+ InspectorTest.expectEqual(object.className, "WebGLRenderingContext", `Payload should have className "WebGLRenderingContext".`);
+ })
+ .then(resolve, reject);
+ }
+ });
+
+ suite.runTestCasesAndFinish();
+}
+</script>
+</head>
+<body _onload_="load()">
+ <p>Tests for the Canvas.resolveCanvasContext command for WebGL contexts.</p>
+</body>
+</html>
Added: trunk/LayoutTests/inspector/canvas/resolveCanvasContext-webgl2-expected.txt (0 => 219150)
--- trunk/LayoutTests/inspector/canvas/resolveCanvasContext-webgl2-expected.txt (rev 0)
+++ trunk/LayoutTests/inspector/canvas/resolveCanvasContext-webgl2-expected.txt 2017-07-05 20:13:56 UTC (rev 219150)
@@ -0,0 +1,8 @@
+Tests for the Canvas.resolveCanvasContext command for WebGL2 contexts.
+
+
+== Running test suite: Canvas.resolveCanvasContextWebGL2
+-- Running test case: Canvas.resolveCanvasContextWebGL2.validIdentifier
+PASS: Payload should have type "object".
+PASS: Payload should have className "WebGL2RenderingContext".
+
Added: trunk/LayoutTests/inspector/canvas/resolveCanvasContext-webgl2.html (0 => 219150)
--- trunk/LayoutTests/inspector/canvas/resolveCanvasContext-webgl2.html (rev 0)
+++ trunk/LayoutTests/inspector/canvas/resolveCanvasContext-webgl2.html 2017-07-05 20:13:56 UTC (rev 219150)
@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script>
+if (window.internals)
+ window.internals.settings.setWebGL2Enabled(true);
+
+function load() {
+ window.contextWebGL2 = document.body.appendChild(document.createElement("canvas")).getContext("webgl2");
+
+ runTest();
+}
+
+function test()
+{
+ let suite = InspectorTest.createAsyncSuite("Canvas.resolveCanvasContextWebGL2");
+
+ suite.addTestCase({
+ name: `Canvas.resolveCanvasContextWebGL2.validIdentifier`,
+ description: "Should return a valid object for the given canvas identifier.",
+ test(resolve, reject) {
+ let canvas = WebInspector.canvasManager.canvases.find((canvas) => canvas.contextType === WebInspector.Canvas.ContextType.WebGL2);
+ if (!canvas) {
+ reject(`Missing Canvas.`);
+ return;
+ }
+
+ const objectGroup = "test";
+ CanvasAgent.resolveCanvasContext(canvas.identifier, objectGroup)
+ .then(({object}) => {
+ InspectorTest.expectEqual(object.type, "object", `Payload should have type "object".`);
+ InspectorTest.expectEqual(object.className, "WebGL2RenderingContext", `Payload should have className "WebGL2RenderingContext".`);
+ })
+ .then(resolve, reject);
+ }
+ });
+
+ suite.runTestCasesAndFinish();
+}
+</script>
+</head>
+<body _onload_="load()">
+ <p>Tests for the Canvas.resolveCanvasContext command for WebGL2 contexts.</p>
+</body>
+</html>
Added: trunk/LayoutTests/inspector/canvas/resolveCanvasContext-webgpu-expected.txt (0 => 219150)
--- trunk/LayoutTests/inspector/canvas/resolveCanvasContext-webgpu-expected.txt (rev 0)
+++ trunk/LayoutTests/inspector/canvas/resolveCanvasContext-webgpu-expected.txt 2017-07-05 20:13:56 UTC (rev 219150)
@@ -0,0 +1,8 @@
+Tests for the Canvas.resolveCanvasContext command for WebGPU contexts.
+
+
+== Running test suite: Canvas.resolveCanvasContextWebGPU
+-- Running test case: Canvas.resolveCanvasContextWebGPU.validIdentifier
+PASS: Payload should have type "object".
+PASS: Payload should have className "WebGPURenderingContext".
+
Added: trunk/LayoutTests/inspector/canvas/resolveCanvasContext-webgpu.html (0 => 219150)
--- trunk/LayoutTests/inspector/canvas/resolveCanvasContext-webgpu.html (rev 0)
+++ trunk/LayoutTests/inspector/canvas/resolveCanvasContext-webgpu.html 2017-07-05 20:13:56 UTC (rev 219150)
@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script>
+if (window.internals)
+ window.internals.settings.setWebGPUEnabled(true);
+
+function load() {
+ window.contextWebGPU = document.body.appendChild(document.createElement("canvas")).getContext("webgpu");
+
+ runTest();
+}
+
+function test()
+{
+ let suite = InspectorTest.createAsyncSuite("Canvas.resolveCanvasContextWebGPU");
+
+ suite.addTestCase({
+ name: `Canvas.resolveCanvasContextWebGPU.validIdentifier`,
+ description: "Should return a valid object for the given canvas identifier.",
+ test(resolve, reject) {
+ let canvas = WebInspector.canvasManager.canvases.find((canvas) => canvas.contextType === WebInspector.Canvas.ContextType.WebGPU);
+ if (!canvas) {
+ reject(`Missing Canvas.`);
+ return;
+ }
+
+ const objectGroup = "test";
+ CanvasAgent.resolveCanvasContext(canvas.identifier, objectGroup)
+ .then(({object}) => {
+ InspectorTest.expectEqual(object.type, "object", `Payload should have type "object".`);
+ InspectorTest.expectEqual(object.className, "WebGPURenderingContext", `Payload should have className "WebGPURenderingContext".`);
+ })
+ .then(resolve, reject);
+ }
+ });
+
+ suite.runTestCasesAndFinish();
+}
+</script>
+</head>
+<body _onload_="load()">
+ <p>Tests for the Canvas.resolveCanvasContext command for WebGPU contexts.</p>
+</body>
+</html>
Modified: trunk/LayoutTests/platform/gtk/TestExpectations (219149 => 219150)
--- trunk/LayoutTests/platform/gtk/TestExpectations 2017-07-05 20:10:19 UTC (rev 219149)
+++ trunk/LayoutTests/platform/gtk/TestExpectations 2017-07-05 20:13:56 UTC (rev 219150)
@@ -595,6 +595,7 @@
webkit.org/b/166536 fast/canvas/webgl/webgl2-texStorage.html [ Skip ]
webkit.org/b/166536 fast/canvas/webgl/webgl2-texture-upload-enums.html [ Skip ]
webkit.org/b/166536 inspector/canvas/create-context-webgl2.html [ Skip ]
+webkit.org/b/166536 inspector/canvas/resolveCanvasContext-webgl2.html [ Skip ]
# These tests reference specific fonts on Mac port.
Bug(GTK) fast/text/font-weights.html [ WontFix ]
@@ -1253,6 +1254,7 @@
# WebGPU is not enabled on GTK+.
fast/canvas/webgpu [ Skip ]
inspector/canvas/create-context-webgpu.html [ Skip ]
+inspector/canvas/resolveCanvasContext-webgpu.html [ Skip ]
# We don't support APPLE_PAY.
http/tests/ssl/applepay [ Skip ]
Modified: trunk/LayoutTests/platform/ios/TestExpectations (219149 => 219150)
--- trunk/LayoutTests/platform/ios/TestExpectations 2017-07-05 20:10:19 UTC (rev 219149)
+++ trunk/LayoutTests/platform/ios/TestExpectations 2017-07-05 20:13:56 UTC (rev 219150)
@@ -36,6 +36,7 @@
# WebGPU is not enabled on iOS Simulator.
fast/canvas/webgpu
inspector/canvas/create-context-webgpu.html [ Skip ]
+inspector/canvas/resolveCanvasContext-webgpu.html [ Skip ]
# Encrypted Media Extensions are not enabled
media/encrypted-media/
Modified: trunk/LayoutTests/platform/win/TestExpectations (219149 => 219150)
--- trunk/LayoutTests/platform/win/TestExpectations 2017-07-05 20:10:19 UTC (rev 219149)
+++ trunk/LayoutTests/platform/win/TestExpectations 2017-07-05 20:13:56 UTC (rev 219150)
@@ -1913,6 +1913,8 @@
http/tests/security/webgl-remote-read-remote-image-blocked-no-crossorigin.html [ Skip ]
inspector/canvas/create-context-webgl.html [ Skip ]
inspector/canvas/create-context-webgl2.html [ Skip ]
+inspector/canvas/resolveCanvasContext-webgl.html [ Skip ]
+inspector/canvas/resolveCanvasContext-webgl2.html [ Skip ]
################################################################################
################# End WebGL Issues #######################
################################################################################
@@ -2382,6 +2384,7 @@
# inspector/debugger/searchInContent-linebreaks.html [ Pass Crash ] # Flaky
inspector/canvas/create-context-webgpu.html [ Skip ]
+inspector/canvas/resolveCanvasContext-webgpu.html [ Skip ]
################################################################################
################# End Inspector Issues ####################
Modified: trunk/Source/_javascript_Core/ChangeLog (219149 => 219150)
--- trunk/Source/_javascript_Core/ChangeLog 2017-07-05 20:10:19 UTC (rev 219149)
+++ trunk/Source/_javascript_Core/ChangeLog 2017-07-05 20:13:56 UTC (rev 219150)
@@ -1,3 +1,14 @@
+2017-07-05 Devin Rousso <drou...@apple.com>
+
+ Web Inspector: Allow users to log any tracked canvas context
+ https://bugs.webkit.org/show_bug.cgi?id=173397
+ <rdar://problem/33111581>
+
+ Reviewed by Joseph Pecoraro.
+
+ * inspector/protocol/Canvas.json:
+ Add `resolveCanvasContext` command that returns a RemoteObject for the given canvas context.
+
2017-07-05 Jonathan Bedard <jbed...@apple.com>
Add WebKitPrivateFrameworkStubs for iOS 11
Modified: trunk/Source/_javascript_Core/inspector/protocol/Canvas.json (219149 => 219150)
--- trunk/Source/_javascript_Core/inspector/protocol/Canvas.json 2017-07-05 20:10:19 UTC (rev 219149)
+++ trunk/Source/_javascript_Core/inspector/protocol/Canvas.json 2017-07-05 20:13:56 UTC (rev 219150)
@@ -71,6 +71,17 @@
"returns": [
{ "name": "content", "type": "string", "description": "Base64-encoded data of the canvas' contents." }
]
+ },
+ {
+ "name": "resolveCanvasContext",
+ "description": "Resolves _javascript_ canvas context object for given canvasId.",
+ "parameters": [
+ { "name": "canvasId", "$ref": "CanvasId", "description": "Canvas identifier." },
+ { "name": "objectGroup", "type": "string", "optional": true, "description": "Symbolic group name that can be used to release multiple objects." }
+ ],
+ "returns": [
+ { "name": "object", "$ref": "Runtime.RemoteObject", "description": "_javascript_ object wrapper for given canvas context." }
+ ]
}
],
"events": [
Modified: trunk/Source/WebCore/ChangeLog (219149 => 219150)
--- trunk/Source/WebCore/ChangeLog 2017-07-05 20:10:19 UTC (rev 219149)
+++ trunk/Source/WebCore/ChangeLog 2017-07-05 20:13:56 UTC (rev 219150)
@@ -1,3 +1,22 @@
+2017-07-05 Devin Rousso <drou...@apple.com>
+
+ Web Inspector: Allow users to log any tracked canvas context
+ https://bugs.webkit.org/show_bug.cgi?id=173397
+ <rdar://problem/33111581>
+
+ Reviewed by Joseph Pecoraro.
+
+ Tests: inspector/canvas/resolveCanvasContext-2d.html
+ inspector/canvas/resolveCanvasContext-webgl.html
+ inspector/canvas/resolveCanvasContext-webgl2.html
+ inspector/canvas/resolveCanvasContext-webgpu.html
+
+ * inspector/InspectorCanvasAgent.h:
+ * inspector/InspectorCanvasAgent.cpp:
+ (WebCore::InspectorCanvasAgent::InspectorCanvasAgent):
+ (WebCore::contextAsScriptValue):
+ (WebCore::InspectorCanvasAgent::resolveCanvasContext):
+
2017-07-05 Emilio Cobos Álvarez <eco...@igalia.com>
Style sharing check for fullscreen element seems bogus.
Modified: trunk/Source/WebCore/inspector/InspectorCanvasAgent.cpp (219149 => 219150)
--- trunk/Source/WebCore/inspector/InspectorCanvasAgent.cpp 2017-07-05 20:10:19 UTC (rev 219149)
+++ trunk/Source/WebCore/inspector/InspectorCanvasAgent.cpp 2017-07-05 20:13:56 UTC (rev 219150)
@@ -33,11 +33,18 @@
#include "InspectorDOMAgent.h"
#include "InspectorPageAgent.h"
#include "InstrumentingAgents.h"
+#include "JSCanvasRenderingContext2D.h"
+#include "JSMainThreadExecState.h"
#include "MainFrame.h"
+#include "ScriptState.h"
#include <inspector/IdentifiersFactory.h>
+#include <inspector/InjectedScript.h>
+#include <inspector/InjectedScriptManager.h>
#include <inspector/InspectorProtocolObjects.h>
+#include <runtime/JSCInlines.h>
#if ENABLE(WEBGL)
+#include "JSWebGLRenderingContext.h"
#include "WebGLContextAttributes.h"
#include "WebGLRenderingContext.h"
#include "WebGLRenderingContextBase.h"
@@ -44,10 +51,12 @@
#endif
#if ENABLE(WEBGL2)
+#include "JSWebGL2RenderingContext.h"
#include "WebGL2RenderingContext.h"
#endif
#if ENABLE(WEBGPU)
+#include "JSWebGPURenderingContext.h"
#include "WebGPURenderingContext.h"
#endif
@@ -59,6 +68,7 @@
: InspectorAgentBase(ASCIILiteral("Canvas"), context)
, m_frontendDispatcher(std::make_unique<Inspector::CanvasFrontendDispatcher>(context.frontendRouter))
, m_backendDispatcher(Inspector::CanvasBackendDispatcher::create(context.backendDispatcher, this))
+ , m_injectedScriptManager(context.injectedScriptManager)
, m_pageAgent(pageAgent)
, m_timer(*this, &InspectorCanvasAgent::canvasDestroyedTimerFired)
{
@@ -145,6 +155,58 @@
}
}
+static JSC::JSValue contextAsScriptValue(JSC::ExecState& state, CanvasRenderingContext* context)
+{
+ JSC::JSLockHolder lock(&state);
+
+ if (is<CanvasRenderingContext2D>(context))
+ return toJS(&state, deprecatedGlobalObjectForPrototype(&state), downcast<CanvasRenderingContext2D>(context));
+#if ENABLE(WEBGL)
+ if (is<WebGLRenderingContext>(context))
+ return toJS(&state, deprecatedGlobalObjectForPrototype(&state), downcast<WebGLRenderingContext>(context));
+#endif
+#if ENABLE(WEBGL2)
+ if (is<WebGL2RenderingContext>(context))
+ return toJS(&state, deprecatedGlobalObjectForPrototype(&state), downcast<WebGL2RenderingContext>(context));
+#endif
+#if ENABLE(WEBGPU)
+ if (is<WebGPURenderingContext>(context))
+ return toJS(&state, deprecatedGlobalObjectForPrototype(&state), downcast<WebGPURenderingContext>(context));
+#endif
+
+ return { };
+}
+
+void InspectorCanvasAgent::resolveCanvasContext(ErrorString& errorString, const String& canvasId, const String* const objectGroup, RefPtr<Inspector::Protocol::Runtime::RemoteObject>& result)
+{
+ const CanvasEntry* canvasEntry = getCanvasEntry(canvasId);
+ if (!canvasEntry) {
+ errorString = ASCIILiteral("Invalid canvas identifier");
+ return;
+ }
+
+ Frame* frame = canvasEntry->element->document().frame();
+ if (!frame) {
+ errorString = ASCIILiteral("Canvas belongs to a document without a frame");
+ return;
+ }
+
+ auto& state = *mainWorldExecState(frame);
+ auto injectedScript = m_injectedScriptManager.injectedScriptFor(&state);
+ ASSERT(!injectedScript.hasNoValue());
+
+ CanvasRenderingContext* context = canvasEntry->element->renderingContext();
+ JSC::JSValue value = contextAsScriptValue(state, context);
+ if (!value) {
+ ASSERT_NOT_REACHED();
+ errorString = ASCIILiteral("Unknown context type");
+ return;
+ }
+
+ String objectGroupName = objectGroup ? *objectGroup : String();
+ result = injectedScript.wrapObject(value, objectGroupName);
+}
+
void InspectorCanvasAgent::frameNavigated(Frame& frame)
{
if (frame.isMainFrame()) {
Modified: trunk/Source/WebCore/inspector/InspectorCanvasAgent.h (219149 => 219150)
--- trunk/Source/WebCore/inspector/InspectorCanvasAgent.h 2017-07-05 20:10:19 UTC (rev 219149)
+++ trunk/Source/WebCore/inspector/InspectorCanvasAgent.h 2017-07-05 20:13:56 UTC (rev 219150)
@@ -36,6 +36,10 @@
#include <wtf/Vector.h>
#include <wtf/text/WTFString.h>
+namespace Inspector {
+class InjectedScriptManager;
+}
+
namespace WebCore {
class InspectorPageAgent;
@@ -59,6 +63,7 @@
void disable(ErrorString&) override;
void requestNode(ErrorString&, const String& canvasId, int* nodeId) override;
void requestContent(ErrorString&, const String& canvasId, String* content) override;
+ void resolveCanvasContext(ErrorString&, const String& canvasId, const String* const objectGroup, RefPtr<Inspector::Protocol::Runtime::RemoteObject>&) override;
// InspectorInstrumentation
void frameNavigated(Frame&);
@@ -94,6 +99,7 @@
std::unique_ptr<Inspector::CanvasFrontendDispatcher> m_frontendDispatcher;
RefPtr<Inspector::CanvasBackendDispatcher> m_backendDispatcher;
+ Inspector::InjectedScriptManager& m_injectedScriptManager;
InspectorPageAgent* m_pageAgent;
HashMap<HTMLCanvasElement*, CanvasEntry> m_canvasEntries;
Modified: trunk/Source/WebInspectorUI/ChangeLog (219149 => 219150)
--- trunk/Source/WebInspectorUI/ChangeLog 2017-07-05 20:10:19 UTC (rev 219149)
+++ trunk/Source/WebInspectorUI/ChangeLog 2017-07-05 20:13:56 UTC (rev 219150)
@@ -1,3 +1,17 @@
+2017-07-05 Devin Rousso <drou...@apple.com>
+
+ Web Inspector: Allow users to log any tracked canvas context
+ https://bugs.webkit.org/show_bug.cgi?id=173397
+ <rdar://problem/33111581>
+
+ Reviewed by Joseph Pecoraro.
+
+ * Localizations/en.lproj/localizedStrings.js:
+ * UserInterface/Protocol/RemoteObject.js:
+ (WebInspector.RemoteObject.resolveCanvasContext):
+ * UserInterface/Views/CanvasTreeElement.js:
+ (WebInspector.CanvasTreeElement.prototype.populateContextMenu):
+
2017-07-03 Devin Rousso <drou...@apple.com>
Web Inspector: Support listing WebGL2 and WebGPU contexts
Modified: trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js (219149 => 219150)
--- trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js 2017-07-05 20:10:19 UTC (rev 219149)
+++ trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js 2017-07-05 20:13:56 UTC (rev 219150)
@@ -491,7 +491,6 @@
localizedStrings["Key Path"] = "Key Path";
localizedStrings["Label"] = "Label";
localizedStrings["Latency"] = "Latency";
-localizedStrings["Layer"] = "Layer";
localizedStrings["Layer Count: %d"] = "Layer Count: %d";
localizedStrings["Layer Info"] = "Layer Info";
localizedStrings["Layers"] = "Layers";
@@ -517,6 +516,7 @@
localizedStrings["Local Variables"] = "Local Variables";
localizedStrings["Located at %s"] = "Located at %s";
localizedStrings["Location"] = "Location";
+localizedStrings["Log Canvas Context"] = "Log Canvas Context";
localizedStrings["Log Element"] = "Log Element";
localizedStrings["Log Frame Text"] = "Log Frame Text";
localizedStrings["Log Frame Value"] = "Log Frame Value";
@@ -739,6 +739,7 @@
localizedStrings["Select comparison snapshot"] = "Select comparison snapshot";
localizedStrings["Select text on first click"] = "Select text on first click";
localizedStrings["Selected"] = "Selected";
+localizedStrings["Selected Canvas Context"] = "Selected Canvas Context";
localizedStrings["Selected Element"] = "Selected Element";
localizedStrings["Selected Frame"] = "Selected Frame";
localizedStrings["Selected Item"] = "Selected Item";
Modified: trunk/Source/WebInspectorUI/UserInterface/Protocol/RemoteObject.js (219149 => 219150)
--- trunk/Source/WebInspectorUI/UserInterface/Protocol/RemoteObject.js 2017-07-05 20:10:19 UTC (rev 219149)
+++ trunk/Source/WebInspectorUI/UserInterface/Protocol/RemoteObject.js 2017-07-05 20:13:56 UTC (rev 219150)
@@ -150,6 +150,18 @@
});
}
+ static resolveCanvasContext(canvas, objectGroup, callback)
+ {
+ console.assert(typeof callback === "function");
+
+ CanvasAgent.resolveCanvasContext(canvas.identifier, objectGroup, (error, object) => {
+ if (error || !object)
+ callback(null);
+ else
+ callback(WebInspector.RemoteObject.fromPayload(object, WebInspector.mainTarget));
+ });
+ }
+
static type(remoteObject)
{
if (remoteObject === null)
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/CanvasTreeElement.js (219149 => 219150)
--- trunk/Source/WebInspectorUI/UserInterface/Views/CanvasTreeElement.js 2017-07-05 20:10:19 UTC (rev 219149)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/CanvasTreeElement.js 2017-07-05 20:13:56 UTC (rev 219150)
@@ -32,4 +32,24 @@
const subtitle = null;
super(["canvas", representedObject.contextType], representedObject.displayName, subtitle, representedObject);
}
+
+ // Protected
+
+ populateContextMenu(contextMenu, event)
+ {
+ super.populateContextMenu(contextMenu, event);
+
+ contextMenu.appendItem(WebInspector.UIString("Log Canvas Context"), () => {
+ WebInspector.RemoteObject.resolveCanvasContext(this.representedObject, WebInspector.RuntimeManager.ConsoleObjectGroup, (remoteObject) => {
+ if (!remoteObject)
+ return;
+
+ const text = WebInspector.UIString("Selected Canvas Context");
+ const addSpecialUserLogClass = true;
+ WebInspector.consoleLogViewController.appendImmediateExecutionWithResult(text, remoteObject, addSpecialUserLogClass);
+ });
+ });
+
+ contextMenu.appendSeparator();
+ }
};