Title: [243763] trunk
Revision
243763
Author
[email protected]
Date
2019-04-02 15:19:05 -0700 (Tue, 02 Apr 2019)

Log Message

Web Inspector: Canvas: add support for showing WebGPU contexts
https://bugs.webkit.org/show_bug.cgi?id=196413
<rdar://problem/49438898>

Reviewed by Timothy Hatcher.

Source/WebCore:

Tests: inspector/canvas/create-context-webgpu.html
       inspector/canvas/resolveCanvasContext-webgpu.html

* Modules/webgpu/GPUCanvasContext.idl:
* Modules/webgpu/GPUCanvasContext.h:
(WebCore::GPUCanvasContext::canvas const): Added.
* Modules/webgpu/GPUCanvasContext.cpp:
(WebCore::GPUCanvasContext::create):

* testing/InternalSettings.idl:
* testing/InternalSettings.h:
* testing/InternalSettings.cpp:
(WebCore::InternalSettings::setWebGPUEnabled): Added.

LayoutTests:

* inspector/canvas/create-context-webgpu.html: Added.
* inspector/canvas/create-context-webgpu-expected.txt: Added.
* inspector/canvas/resolveCanvasContext-webgpu.html: Added.
* inspector/canvas/resolveCanvasContext-webgpu-expected.txt: Added.

* inspector/canvas/resources/create-context-utilities.js:
(createDetachedCanvas):
(createCSSCanvas):
(destroyCanvases):
(TestPage.registerInitializer.InspectorTest.CreateContextUtilities.initializeTestSuite): Added.
(TestPage.registerInitializer.InspectorTest.CreateContextUtilities.addSimpleTestCase): Added.
(TestPage.registerInitializer.InspectorTest.CreateContextUtilities.addCSSCanvasTestCase): Added.
(TestPage.registerInitializer.window.initializeTestSuite): Deleted.
(TestPage.registerInitializer.window.addSimpleTestCase): Deleted.
(TestPage.registerInitializer.window.addCSSCanvasTestCase): Deleted.

* inspector/canvas/create-context-2d.html:
* inspector/canvas/create-context-2d-expected.txt:
* inspector/canvas/create-context-bitmaprenderer.html:
* inspector/canvas/create-context-bitmaprenderer-expected.txt:
* inspector/canvas/create-context-webgl.html:
* inspector/canvas/create-context-webgl-expected.txt:
* inspector/canvas/create-context-webgl2.html:
* inspector/canvas/create-context-webgl2-expected.txt:

* platform/gtk/TestExpectations:
* platform/ios/TestExpectations:
* platform/mac-wk1/TestExpectations:
* platform/mac/TestExpectations:
* platform/win/TestExpectations:
* platform/wincairo/TestExpectations:
* platform/wpe/TestExpectations:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (243762 => 243763)


--- trunk/LayoutTests/ChangeLog	2019-04-02 21:43:24 UTC (rev 243762)
+++ trunk/LayoutTests/ChangeLog	2019-04-02 22:19:05 UTC (rev 243763)
@@ -1,3 +1,44 @@
+2019-04-02  Devin Rousso  <[email protected]>
+
+        Web Inspector: Canvas: add support for showing WebGPU contexts
+        https://bugs.webkit.org/show_bug.cgi?id=196413
+        <rdar://problem/49438898>
+
+        Reviewed by Timothy Hatcher.
+
+        * inspector/canvas/create-context-webgpu.html: Added.
+        * inspector/canvas/create-context-webgpu-expected.txt: Added.
+        * inspector/canvas/resolveCanvasContext-webgpu.html: Added.
+        * inspector/canvas/resolveCanvasContext-webgpu-expected.txt: Added.
+
+        * inspector/canvas/resources/create-context-utilities.js:
+        (createDetachedCanvas):
+        (createCSSCanvas):
+        (destroyCanvases):
+        (TestPage.registerInitializer.InspectorTest.CreateContextUtilities.initializeTestSuite): Added.
+        (TestPage.registerInitializer.InspectorTest.CreateContextUtilities.addSimpleTestCase): Added.
+        (TestPage.registerInitializer.InspectorTest.CreateContextUtilities.addCSSCanvasTestCase): Added.
+        (TestPage.registerInitializer.window.initializeTestSuite): Deleted.
+        (TestPage.registerInitializer.window.addSimpleTestCase): Deleted.
+        (TestPage.registerInitializer.window.addCSSCanvasTestCase): Deleted.
+
+        * inspector/canvas/create-context-2d.html:
+        * inspector/canvas/create-context-2d-expected.txt:
+        * inspector/canvas/create-context-bitmaprenderer.html:
+        * inspector/canvas/create-context-bitmaprenderer-expected.txt:
+        * inspector/canvas/create-context-webgl.html:
+        * inspector/canvas/create-context-webgl-expected.txt:
+        * inspector/canvas/create-context-webgl2.html:
+        * inspector/canvas/create-context-webgl2-expected.txt:
+
+        * platform/gtk/TestExpectations:
+        * platform/ios/TestExpectations:
+        * platform/mac-wk1/TestExpectations:
+        * platform/mac/TestExpectations:
+        * platform/win/TestExpectations:
+        * platform/wincairo/TestExpectations:
+        * platform/wpe/TestExpectations:
+
 2019-04-02  Chris Dumez  <[email protected]>
 
         [WK2] Add support for Window's beforeprint / afterprint events

Modified: trunk/LayoutTests/inspector/canvas/create-context-2d-expected.txt (243762 => 243763)


--- trunk/LayoutTests/inspector/canvas/create-context-2d-expected.txt	2019-04-02 21:43:24 UTC (rev 243762)
+++ trunk/LayoutTests/inspector/canvas/create-context-2d-expected.txt	2019-04-02 22:19:05 UTC (rev 243763)
@@ -19,7 +19,7 @@
 -- Running test case: Canvas.CreateContext2D.Detached
 PASS: Canvas context should be 2D.
   0: getContext - [native code]
-  1: createDetachedCanvas - inspector/canvas/resources/create-context-utilities.js:8:62
+  1: createDetachedCanvas - inspector/canvas/resources/create-context-utilities.js:11:62
   2: Global Code - [program code]
   3: evaluateWithScopeExtension - [native code]
   4: (anonymous function) - [native code]
@@ -31,7 +31,7 @@
 Create CSS canvas from -webkit-canvas(css-canvas).
 PASS: Canvas context should be 2D.
   0: getCSSCanvasContext - [native code]
-  1: createCSSCanvas - inspector/canvas/resources/create-context-utilities.js:12:47
+  1: createCSSCanvas - inspector/canvas/resources/create-context-utilities.js:18:47
   2: Global Code - [program code]
   3: evaluateWithScopeExtension - [native code]
   4: (anonymous function) - [native code]

Modified: trunk/LayoutTests/inspector/canvas/create-context-2d.html (243762 => 243763)


--- trunk/LayoutTests/inspector/canvas/create-context-2d.html	2019-04-02 21:43:24 UTC (rev 243762)
+++ trunk/LayoutTests/inspector/canvas/create-context-2d.html	2019-04-02 22:19:05 UTC (rev 243763)
@@ -6,21 +6,21 @@
 <script src=""
 <script>
 function test() {
-    let suite = initializeTestSuite("Canvas.CreateContext2D");
+    let suite = InspectorTest.CreateContextUtilities.initializeTestSuite("Canvas.CreateContext2D");
 
-    addSimpleTestCase({
+    InspectorTest.CreateContextUtilities.addSimpleTestCase({
         name: "Attached",
         _expression_: `createAttachedCanvas("2d")`,
         contextType: WI.Canvas.ContextType.Canvas2D,
     });
 
-    addSimpleTestCase({
+    InspectorTest.CreateContextUtilities.addSimpleTestCase({
         name: "Detached",
         _expression_: `createDetachedCanvas("2d")`,
         contextType: WI.Canvas.ContextType.Canvas2D,
     });
 
-    addCSSCanvasTestCase(WI.Canvas.ContextType.Canvas2D);
+    InspectorTest.CreateContextUtilities.addCSSCanvasTestCase(WI.Canvas.ContextType.Canvas2D);
 
     suite.runTestCasesAndFinish();
 }

Modified: trunk/LayoutTests/inspector/canvas/create-context-bitmaprenderer-expected.txt (243762 => 243763)


--- trunk/LayoutTests/inspector/canvas/create-context-bitmaprenderer-expected.txt	2019-04-02 21:43:24 UTC (rev 243762)
+++ trunk/LayoutTests/inspector/canvas/create-context-bitmaprenderer-expected.txt	2019-04-02 22:19:05 UTC (rev 243763)
@@ -19,7 +19,7 @@
 -- Running test case: Canvas.CreateContextBitmapRenderer.Detached
 PASS: Canvas context should be Bitmap Renderer.
   0: getContext - [native code]
-  1: createDetachedCanvas - inspector/canvas/resources/create-context-utilities.js:8:62
+  1: createDetachedCanvas - inspector/canvas/resources/create-context-utilities.js:11:62
   2: Global Code - [program code]
   3: evaluateWithScopeExtension - [native code]
   4: (anonymous function) - [native code]

Modified: trunk/LayoutTests/inspector/canvas/create-context-bitmaprenderer.html (243762 => 243763)


--- trunk/LayoutTests/inspector/canvas/create-context-bitmaprenderer.html	2019-04-02 21:43:24 UTC (rev 243762)
+++ trunk/LayoutTests/inspector/canvas/create-context-bitmaprenderer.html	2019-04-02 22:19:05 UTC (rev 243763)
@@ -6,15 +6,15 @@
 <script src=""
 <script>
 function test() {
-    let suite = initializeTestSuite("Canvas.CreateContextBitmapRenderer");
+    let suite = InspectorTest.CreateContextUtilities.initializeTestSuite("Canvas.CreateContextBitmapRenderer");
 
-    addSimpleTestCase({
+    InspectorTest.CreateContextUtilities.addSimpleTestCase({
         name: "Attached",
         _expression_: `createAttachedCanvas("bitmaprenderer")`,
         contextType: WI.Canvas.ContextType.BitmapRenderer,
     });
 
-    addSimpleTestCase({
+    InspectorTest.CreateContextUtilities.addSimpleTestCase({
         name: "Detached",
         _expression_: `createDetachedCanvas("bitmaprenderer")`,
         contextType: WI.Canvas.ContextType.BitmapRenderer,

Modified: trunk/LayoutTests/inspector/canvas/create-context-webgl-expected.txt (243762 => 243763)


--- trunk/LayoutTests/inspector/canvas/create-context-webgl-expected.txt	2019-04-02 21:43:24 UTC (rev 243762)
+++ trunk/LayoutTests/inspector/canvas/create-context-webgl-expected.txt	2019-04-02 22:19:05 UTC (rev 243763)
@@ -19,7 +19,7 @@
 -- Running test case: Canvas.CreateContextWebGL.Detached
 PASS: Canvas context should be WebGL.
   0: getContext - [native code]
-  1: createDetachedCanvas - inspector/canvas/resources/create-context-utilities.js:8:62
+  1: createDetachedCanvas - inspector/canvas/resources/create-context-utilities.js:11:62
   2: Global Code - [program code]
   3: evaluateWithScopeExtension - [native code]
   4: (anonymous function) - [native code]
@@ -31,7 +31,7 @@
 Create CSS canvas from -webkit-canvas(css-canvas).
 PASS: Canvas context should be WebGL.
   0: getCSSCanvasContext - [native code]
-  1: createCSSCanvas - inspector/canvas/resources/create-context-utilities.js:12:47
+  1: createCSSCanvas - inspector/canvas/resources/create-context-utilities.js:18:47
   2: Global Code - [program code]
   3: evaluateWithScopeExtension - [native code]
   4: (anonymous function) - [native code]

Modified: trunk/LayoutTests/inspector/canvas/create-context-webgl.html (243762 => 243763)


--- trunk/LayoutTests/inspector/canvas/create-context-webgl.html	2019-04-02 21:43:24 UTC (rev 243762)
+++ trunk/LayoutTests/inspector/canvas/create-context-webgl.html	2019-04-02 22:19:05 UTC (rev 243763)
@@ -6,21 +6,21 @@
 <script src=""
 <script>
 function test() {
-    let suite = initializeTestSuite("Canvas.CreateContextWebGL");
+    let suite = InspectorTest.CreateContextUtilities.initializeTestSuite("Canvas.CreateContextWebGL");
 
-    addSimpleTestCase({
+    InspectorTest.CreateContextUtilities.addSimpleTestCase({
         name: "Attached",
         _expression_: `createAttachedCanvas("webgl")`,
         contextType: WI.Canvas.ContextType.WebGL,
     });
 
-    addSimpleTestCase({
+    InspectorTest.CreateContextUtilities.addSimpleTestCase({
         name: "Detached",
         _expression_: `createDetachedCanvas("webgl")`,
         contextType: WI.Canvas.ContextType.WebGL,
     });
 
-    addCSSCanvasTestCase(WI.Canvas.ContextType.WebGL);
+    InspectorTest.CreateContextUtilities.addCSSCanvasTestCase(WI.Canvas.ContextType.WebGL);
 
     suite.runTestCasesAndFinish();
 }

Modified: trunk/LayoutTests/inspector/canvas/create-context-webgl2-expected.txt (243762 => 243763)


--- trunk/LayoutTests/inspector/canvas/create-context-webgl2-expected.txt	2019-04-02 21:43:24 UTC (rev 243762)
+++ trunk/LayoutTests/inspector/canvas/create-context-webgl2-expected.txt	2019-04-02 22:19:05 UTC (rev 243763)
@@ -19,7 +19,7 @@
 -- Running test case: Canvas.CreateContextWebGL2.Detached
 PASS: Canvas context should be WebGL2.
   0: getContext - [native code]
-  1: createDetachedCanvas - inspector/canvas/resources/create-context-utilities.js:8:62
+  1: createDetachedCanvas - inspector/canvas/resources/create-context-utilities.js:11:62
   2: Global Code - [program code]
   3: evaluateWithScopeExtension - [native code]
   4: (anonymous function) - [native code]
@@ -31,7 +31,7 @@
 Create CSS canvas from -webkit-canvas(css-canvas).
 PASS: Canvas context should be WebGL2.
   0: getCSSCanvasContext - [native code]
-  1: createCSSCanvas - inspector/canvas/resources/create-context-utilities.js:12:47
+  1: createCSSCanvas - inspector/canvas/resources/create-context-utilities.js:18:47
   2: Global Code - [program code]
   3: evaluateWithScopeExtension - [native code]
   4: (anonymous function) - [native code]

Modified: trunk/LayoutTests/inspector/canvas/create-context-webgl2.html (243762 => 243763)


--- trunk/LayoutTests/inspector/canvas/create-context-webgl2.html	2019-04-02 21:43:24 UTC (rev 243762)
+++ trunk/LayoutTests/inspector/canvas/create-context-webgl2.html	2019-04-02 22:19:05 UTC (rev 243763)
@@ -9,21 +9,21 @@
     window.internals.settings.setWebGL2Enabled(true);
 
 function test() {
-    let suite = initializeTestSuite("Canvas.CreateContextWebGL2");
+    let suite = InspectorTest.CreateContextUtilities.initializeTestSuite("Canvas.CreateContextWebGL2");
 
-    addSimpleTestCase({
+    InspectorTest.CreateContextUtilities.addSimpleTestCase({
         name: "Attached",
         _expression_: `createAttachedCanvas("webgl2")`,
         contextType: WI.Canvas.ContextType.WebGL2,
     });
 
-    addSimpleTestCase({
+    InspectorTest.CreateContextUtilities.addSimpleTestCase({
         name: "Detached",
         _expression_: `createDetachedCanvas("webgl2")`,
         contextType: WI.Canvas.ContextType.WebGL2,
     });
 
-    addCSSCanvasTestCase(WI.Canvas.ContextType.WebGL2);
+    InspectorTest.CreateContextUtilities.addCSSCanvasTestCase(WI.Canvas.ContextType.WebGL2);
 
     suite.runTestCasesAndFinish();
 }

Copied: trunk/LayoutTests/inspector/canvas/create-context-webgpu-expected.txt (from rev 243762, trunk/LayoutTests/inspector/canvas/create-context-webgl-expected.txt) (0 => 243763)


--- trunk/LayoutTests/inspector/canvas/create-context-webgpu-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector/canvas/create-context-webgpu-expected.txt	2019-04-02 22:19:05 UTC (rev 243763)
@@ -0,0 +1,41 @@
+Test that CanvasManager tracks creation and destruction of WebGPU canvases.
+
+
+== Running test suite: Canvas.CreateContextWebGPU
+-- Running test case: Canvas.CreateContextWebGPU.NoCanvases
+PASS: CanvasManager should have no canvases.
+
+-- Running test case: Canvas.CreateContextWebGPU.Attached
+PASS: Canvas context should be Web GPU.
+  0: getContext - [native code]
+  1: createAttachedCanvas - inspector/canvas/resources/create-context-utilities.js:4:36
+  2: Global Code - [program code]
+  3: evaluateWithScopeExtension - [native code]
+  4: (anonymous function) - [native code]
+  5: _wrapCall - [native code]
+
+PASS: Removed canvas has expected ID.
+
+-- Running test case: Canvas.CreateContextWebGPU.Detached
+PASS: Canvas context should be Web GPU.
+  0: getContext - [native code]
+  1: createDetachedCanvas - inspector/canvas/resources/create-context-utilities.js:11:62
+  2: Global Code - [program code]
+  3: evaluateWithScopeExtension - [native code]
+  4: (anonymous function) - [native code]
+  5: _wrapCall - [native code]
+
+PASS: Removed canvas has expected ID.
+
+-- Running test case: Canvas.CreateContextWebGPU.CSSCanvas
+Create CSS canvas from -webkit-canvas(css-canvas).
+PASS: Canvas context should be Web GPU.
+  0: getCSSCanvasContext - [native code]
+  1: createCSSCanvas - inspector/canvas/resources/create-context-utilities.js:18:47
+  2: Global Code - [program code]
+  3: evaluateWithScopeExtension - [native code]
+  4: (anonymous function) - [native code]
+  5: _wrapCall - [native code]
+
+PASS: Canvas name should equal the identifier passed to -webkit-canvas.
+

Added: trunk/LayoutTests/inspector/canvas/create-context-webgpu.html (0 => 243763)


--- trunk/LayoutTests/inspector/canvas/create-context-webgpu.html	                        (rev 0)
+++ trunk/LayoutTests/inspector/canvas/create-context-webgpu.html	2019-04-02 22:19:05 UTC (rev 243763)
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="stylesheet" href=""
+<script src=""
+<script src=""
+<script>
+if (window.internals)
+    window.internals.settings.setWebGPUEnabled(true);
+
+function test() {
+    InspectorTest.debug();
+
+    let suite = InspectorTest.CreateContextUtilities.initializeTestSuite("Canvas.CreateContextWebGPU");
+
+    InspectorTest.CreateContextUtilities.addSimpleTestCase({
+        name: "Attached",
+        _expression_: `createAttachedCanvas("gpu")`,
+        contextType: WI.Canvas.ContextType.WebGPU,
+    });
+
+    InspectorTest.CreateContextUtilities.addSimpleTestCase({
+        name: "Detached",
+        _expression_: `createDetachedCanvas("gpu")`,
+        contextType: WI.Canvas.ContextType.WebGPU,
+    });
+
+    InspectorTest.CreateContextUtilities.addCSSCanvasTestCase(WI.Canvas.ContextType.WebGPU);
+
+    suite.runTestCasesAndFinish();
+}
+</script>
+</head>
+<body _onload_="runTest()">
+    <p>Test that CanvasManager tracks creation and destruction of WebGPU canvases.</p>
+</body>
+</html>

Added: trunk/LayoutTests/inspector/canvas/resolveCanvasContext-webgpu-expected.txt (0 => 243763)


--- trunk/LayoutTests/inspector/canvas/resolveCanvasContext-webgpu-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector/canvas/resolveCanvasContext-webgpu-expected.txt	2019-04-02 22:19:05 UTC (rev 243763)
@@ -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 "GPUCanvasContext".
+

Added: trunk/LayoutTests/inspector/canvas/resolveCanvasContext-webgpu.html (0 => 243763)


--- trunk/LayoutTests/inspector/canvas/resolveCanvasContext-webgpu.html	                        (rev 0)
+++ trunk/LayoutTests/inspector/canvas/resolveCanvasContext-webgpu.html	2019-04-02 22:19:05 UTC (rev 243763)
@@ -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("gpu");
+
+    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 = WI.canvasManager.canvases.find((canvas) => canvas.contextType === WI.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, "GPUCanvasContext", `Payload should have className "GPUCanvasContext".`);
+            })
+            .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/inspector/canvas/resources/create-context-utilities.js (243762 => 243763)


--- trunk/LayoutTests/inspector/canvas/resources/create-context-utilities.js	2019-04-02 21:43:24 UTC (rev 243762)
+++ trunk/LayoutTests/inspector/canvas/resources/create-context-utilities.js	2019-04-02 22:19:05 UTC (rev 243763)
@@ -2,19 +2,31 @@
 
 function createAttachedCanvas(contextType) {
     let canvas = document.body.appendChild(document.createElement("canvas"));
-    contexts.push(canvas.getContext(contextType));
+    let context = canvas.getContext(contextType);
+    if (!context)
+        TestPage.addResult("FAIL: missing context for type " + contextType);
+    contexts.push(context);
 }
 
 function createDetachedCanvas(contextType) {
-    contexts.push(document.createElement("canvas").getContext(contextType));
+    let context = document.createElement("canvas").getContext(contextType);
+    if (!context)
+        TestPage.addResult("FAIL: missing context for type " + contextType);
+    contexts.push(context);
 }
 
 function createCSSCanvas(contextType, canvasName) {
-    contexts.push(document.getCSSCanvasContext(contextType, canvasName, 10, 10));
+    let context = document.getCSSCanvasContext(contextType, canvasName, 10, 10);
+    if (!context)
+        TestPage.addResult("FAIL: missing context for type " + contextType);
+    contexts.push();
 }
 
 function destroyCanvases() {
     for (let context of contexts) {
+        if (!context)
+            continue;
+
         let canvasElement = context.canvas;
         if (canvasElement && canvasElement.parentNode)
             canvasElement.remove();
@@ -68,7 +80,9 @@
         });
     }
 
-    window.initializeTestSuite = function(name) {
+    InspectorTest.CreateContextUtilities = {};
+
+    InspectorTest.CreateContextUtilities.initializeTestSuite = function(name) {
         suite = InspectorTest.createAsyncSuite(name);
 
         suite.addTestCase({
@@ -83,7 +97,7 @@
         return suite;
     };
 
-    window.addSimpleTestCase = function({name, description, _expression_, contextType}) {
+    InspectorTest.CreateContextUtilities.addSimpleTestCase = function({name, description, _expression_, contextType}) {
         suite.addTestCase({
             name: suite.name + "." + name,
             description,
@@ -108,7 +122,7 @@
     };
 
     let previousCSSCanvasContextType = null;
-    window.addCSSCanvasTestCase = function(contextType) {
+    InspectorTest.CreateContextUtilities.addCSSCanvasTestCase = function(contextType) {
         InspectorTest.assert(!previousCSSCanvasContextType || previousCSSCanvasContextType === contextType, "addCSSCanvasTestCase cannot be called more than once with different context types.");
         if (!previousCSSCanvasContextType)
             previousCSSCanvasContextType = contextType;
@@ -123,7 +137,14 @@
                 })
                 .then(resolve, reject);
 
-                let contextId = contextType === WI.Canvas.ContextType.Canvas2D ? "2d" : contextType;
+                let contextId = null;
+                if (contextType === WI.Canvas.ContextType.Canvas2D)
+                    contextId = "2d";
+                else if (contextType === WI.Canvas.ContextType.WebGPU)
+                    contextId = "gpu";
+                else
+                    contextId = contextType;
+
                 InspectorTest.log(`Create CSS canvas from -webkit-canvas(css-canvas).`);
                 InspectorTest.evaluateInPage(`createCSSCanvas("${contextId}", "css-canvas")`);
             },

Modified: trunk/LayoutTests/platform/gtk/TestExpectations (243762 => 243763)


--- trunk/LayoutTests/platform/gtk/TestExpectations	2019-04-02 21:43:24 UTC (rev 243762)
+++ trunk/LayoutTests/platform/gtk/TestExpectations	2019-04-02 22:19:05 UTC (rev 243763)
@@ -1236,6 +1236,8 @@
 
 # No support for WebGPU yet
 webkit.org/b/191005 webgpu/ [ Skip ]
+webkit.org/b/191005 inspector/canvas/create-context-webgpu.html [ Skip ]
+webkit.org/b/191005 inspector/canvas/resolveCanvasContext-webgpu.html [ Skip ]
 
 # No support for resource load statistics yet
 http/tests/resourceLoadStatistics/ [ Skip ]

Modified: trunk/LayoutTests/platform/ios/TestExpectations (243762 => 243763)


--- trunk/LayoutTests/platform/ios/TestExpectations	2019-04-02 21:43:24 UTC (rev 243762)
+++ trunk/LayoutTests/platform/ios/TestExpectations	2019-04-02 22:19:05 UTC (rev 243763)
@@ -41,6 +41,8 @@
 
 # WebGPU is not enabled on iOS Simulator.
 webgpu [ Skip ]
+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/mac/TestExpectations (243762 => 243763)


--- trunk/LayoutTests/platform/mac/TestExpectations	2019-04-02 21:43:24 UTC (rev 243762)
+++ trunk/LayoutTests/platform/mac/TestExpectations	2019-04-02 22:19:05 UTC (rev 243763)
@@ -1779,6 +1779,8 @@
 webkit.org/b/190976 imported/w3c/web-platform-tests/media-source/mediasource-changetype-play.html [ Pass Failure ]
 
 webkit.org/b/192956 [ Sierra ] webgpu [ Skip ]
+webkit.org/b/192956 [ Sierra ] inspector/canvas/create-context-webgpu.html [ Skip ]
+webkit.org/b/192956 [ Sierra ] inspector/canvas/resolveCanvasContext-webgpu.html [ Skip ]
 
 webkit.org/b/189680 platform/mac/media/audio-session-category-video-paused.html [ Pass Timeout ]
 

Modified: trunk/LayoutTests/platform/mac-wk1/TestExpectations (243762 => 243763)


--- trunk/LayoutTests/platform/mac-wk1/TestExpectations	2019-04-02 21:43:24 UTC (rev 243762)
+++ trunk/LayoutTests/platform/mac-wk1/TestExpectations	2019-04-02 22:19:05 UTC (rev 243763)
@@ -43,7 +43,10 @@
 css-custom-properties-api [ Skip ]
 css-typedom [ Skip ]
 css-dark-mode [ Skip ]
+
 webgpu [ Skip ]
+inspector/canvas/create-context-webgpu.html [ Skip ]
+inspector/canvas/resolveCanvasContext-webgpu.html [ Skip ]
 
 # Media Stream API testing is not supported for WK1 yet.
 fast/mediastream

Modified: trunk/LayoutTests/platform/win/TestExpectations (243762 => 243763)


--- trunk/LayoutTests/platform/win/TestExpectations	2019-04-02 21:43:24 UTC (rev 243762)
+++ trunk/LayoutTests/platform/win/TestExpectations	2019-04-02 22:19:05 UTC (rev 243763)
@@ -4217,6 +4217,8 @@
 
 # WebGPU is not supported on Windows
 webgpu [ Skip ]
+inspector/canvas/create-context-webgpu.html [ Skip ]
+inspector/canvas/resolveCanvasContext-webgpu.html [ Skip ]
 
 webkit.org/b/191194 fast/block/basic/inline-content-with-floating-image.html [ Failure ]
 webkit.org/b/191194 fast/block/basic/inline-content-with-floating-images2.html [ Failure ]

Modified: trunk/LayoutTests/platform/wincairo/TestExpectations (243762 => 243763)


--- trunk/LayoutTests/platform/wincairo/TestExpectations	2019-04-02 21:43:24 UTC (rev 243762)
+++ trunk/LayoutTests/platform/wincairo/TestExpectations	2019-04-02 22:19:05 UTC (rev 243763)
@@ -291,6 +291,8 @@
 
 # WEBGPU is disabled
 webgpu [ Skip ]
+inspector/canvas/create-context-webgpu.html [ Skip ]
+inspector/canvas/resolveCanvasContext-webgpu.html [ Skip ]
 
 # WIRELESS_PLAYBACK_TARGET is disabled
 media/airplay-target-availability.html [ Skip ]

Modified: trunk/LayoutTests/platform/wpe/TestExpectations (243762 => 243763)


--- trunk/LayoutTests/platform/wpe/TestExpectations	2019-04-02 21:43:24 UTC (rev 243762)
+++ trunk/LayoutTests/platform/wpe/TestExpectations	2019-04-02 22:19:05 UTC (rev 243763)
@@ -295,6 +295,8 @@
 
 # No WebGPU support yet
 webgpu [ Skip ]
+inspector/canvas/create-context-webgpu.html [ Skip ]
+inspector/canvas/resolveCanvasContext-webgpu.html [ Skip ]
 
 # Skipped due to untestable DRM key system. ClearKey counterparts are tested instead.
 imported/w3c/web-platform-tests/encrypted-media/drm-check-initdata-type.https.html [ Skip ]

Modified: trunk/Source/WebCore/ChangeLog (243762 => 243763)


--- trunk/Source/WebCore/ChangeLog	2019-04-02 21:43:24 UTC (rev 243762)
+++ trunk/Source/WebCore/ChangeLog	2019-04-02 22:19:05 UTC (rev 243763)
@@ -1,3 +1,25 @@
+2019-04-02  Devin Rousso  <[email protected]>
+
+        Web Inspector: Canvas: add support for showing WebGPU contexts
+        https://bugs.webkit.org/show_bug.cgi?id=196413
+        <rdar://problem/49438898>
+
+        Reviewed by Timothy Hatcher.
+
+        Tests: inspector/canvas/create-context-webgpu.html
+               inspector/canvas/resolveCanvasContext-webgpu.html
+
+        * Modules/webgpu/GPUCanvasContext.idl:
+        * Modules/webgpu/GPUCanvasContext.h:
+        (WebCore::GPUCanvasContext::canvas const): Added.
+        * Modules/webgpu/GPUCanvasContext.cpp:
+        (WebCore::GPUCanvasContext::create):
+
+        * testing/InternalSettings.idl:
+        * testing/InternalSettings.h:
+        * testing/InternalSettings.cpp:
+        (WebCore::InternalSettings::setWebGPUEnabled): Added.
+
 2019-04-02  Chris Dumez  <[email protected]>
 
         [WK2] Add support for Window's beforeprint / afterprint events

Modified: trunk/Source/WebCore/Modules/webgpu/GPUCanvasContext.cpp (243762 => 243763)


--- trunk/Source/WebCore/Modules/webgpu/GPUCanvasContext.cpp	2019-04-02 21:43:24 UTC (rev 243762)
+++ trunk/Source/WebCore/Modules/webgpu/GPUCanvasContext.cpp	2019-04-02 22:19:05 UTC (rev 243763)
@@ -26,6 +26,8 @@
 #include "config.h"
 #include "GPUCanvasContext.h"
 
+#include "InspectorInstrumentation.h"
+
 #if ENABLE(WEBGPU)
 
 namespace WebCore {
@@ -34,6 +36,9 @@
 {
     auto context = std::unique_ptr<GPUCanvasContext>(new GPUCanvasContext(canvas));
     context->suspendIfNeeded();
+
+    InspectorInstrumentation::didCreateCanvasRenderingContext(*context);
+
     return context;
 }
 

Modified: trunk/Source/WebCore/Modules/webgpu/GPUCanvasContext.h (243762 => 243763)


--- trunk/Source/WebCore/Modules/webgpu/GPUCanvasContext.h	2019-04-02 21:43:24 UTC (rev 243762)
+++ trunk/Source/WebCore/Modules/webgpu/GPUCanvasContext.h	2019-04-02 22:19:05 UTC (rev 243763)
@@ -28,6 +28,7 @@
 #if ENABLE(WEBGPU)
 
 #include "GPUBasedCanvasRenderingContext.h"
+#include "HTMLCanvasElement.h"
 #include "WebGPUSwapChain.h"
 #include <wtf/RefPtr.h>
 
@@ -37,6 +38,8 @@
 public:
     static std::unique_ptr<GPUCanvasContext> create(CanvasBase&);
 
+    HTMLCanvasElement& canvas() const { return downcast<HTMLCanvasElement>(canvasBase()); }
+
     void replaceSwapChain(Ref<WebGPUSwapChain>&&);
 
 private:

Modified: trunk/Source/WebCore/Modules/webgpu/GPUCanvasContext.idl (243762 => 243763)


--- trunk/Source/WebCore/Modules/webgpu/GPUCanvasContext.idl	2019-04-02 21:43:24 UTC (rev 243762)
+++ trunk/Source/WebCore/Modules/webgpu/GPUCanvasContext.idl	2019-04-02 22:19:05 UTC (rev 243763)
@@ -28,4 +28,6 @@
     Conditional=WEBGPU,
     EnabledAtRuntime=WebGPU
 ] interface GPUCanvasContext {
+    // back-reference to the canvas
+    readonly attribute HTMLCanvasElement canvas;
 };

Modified: trunk/Source/WebCore/testing/InternalSettings.cpp (243762 => 243763)


--- trunk/Source/WebCore/testing/InternalSettings.cpp	2019-04-02 21:43:24 UTC (rev 243762)
+++ trunk/Source/WebCore/testing/InternalSettings.cpp	2019-04-02 22:19:05 UTC (rev 243763)
@@ -758,6 +758,15 @@
 #endif
 }
 
+void InternalSettings::setWebGPUEnabled(bool enabled)
+{
+#if ENABLE(WEBGPU)
+    RuntimeEnabledFeatures::sharedFeatures().setWebGPUEnabled(enabled);
+#else
+    UNUSED_PARAM(enabled);
+#endif
+}
+
 void InternalSettings::setWebVREnabled(bool enabled)
 {
     RuntimeEnabledFeatures::sharedFeatures().setWebVREnabled(enabled);

Modified: trunk/Source/WebCore/testing/InternalSettings.h (243762 => 243763)


--- trunk/Source/WebCore/testing/InternalSettings.h	2019-04-02 21:43:24 UTC (rev 243762)
+++ trunk/Source/WebCore/testing/InternalSettings.h	2019-04-02 22:19:05 UTC (rev 243763)
@@ -123,6 +123,7 @@
     // RuntimeEnabledFeatures.
     static void setIndexedDBWorkersEnabled(bool);
     static void setWebGL2Enabled(bool);
+    static void setWebGPUEnabled(bool);
     static void setWebVREnabled(bool);
     static void setScreenCaptureEnabled(bool);
 

Modified: trunk/Source/WebCore/testing/InternalSettings.idl (243762 => 243763)


--- trunk/Source/WebCore/testing/InternalSettings.idl	2019-04-02 21:43:24 UTC (rev 243762)
+++ trunk/Source/WebCore/testing/InternalSettings.idl	2019-04-02 22:19:05 UTC (rev 243763)
@@ -91,6 +91,7 @@
     // RuntimeEnabledFeatures.
     void setIndexedDBWorkersEnabled(boolean enabled);
     void setWebGL2Enabled(boolean enabled);
+    void setWebGPUEnabled(boolean enabled);
     void setWebVREnabled(boolean enabled);
     void setScreenCaptureEnabled(boolean enabled);
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to