Web Inspector: Canvas: add support for showing WebGPU contexts
authordrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 2 Apr 2019 22:19:05 +0000 (22:19 +0000)
committerdrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 2 Apr 2019 22:19:05 +0000 (22:19 +0000)
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:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243763 268f45cc-cd09-0410-ab3c-d52691b4dbfc

28 files changed:
LayoutTests/ChangeLog
LayoutTests/inspector/canvas/create-context-2d-expected.txt
LayoutTests/inspector/canvas/create-context-2d.html
LayoutTests/inspector/canvas/create-context-bitmaprenderer-expected.txt
LayoutTests/inspector/canvas/create-context-bitmaprenderer.html
LayoutTests/inspector/canvas/create-context-webgl-expected.txt
LayoutTests/inspector/canvas/create-context-webgl.html
LayoutTests/inspector/canvas/create-context-webgl2-expected.txt
LayoutTests/inspector/canvas/create-context-webgl2.html
LayoutTests/inspector/canvas/create-context-webgpu-expected.txt [new file with mode: 0644]
LayoutTests/inspector/canvas/create-context-webgpu.html [new file with mode: 0644]
LayoutTests/inspector/canvas/resolveCanvasContext-webgpu-expected.txt [new file with mode: 0644]
LayoutTests/inspector/canvas/resolveCanvasContext-webgpu.html [new file with mode: 0644]
LayoutTests/inspector/canvas/resources/create-context-utilities.js
LayoutTests/platform/gtk/TestExpectations
LayoutTests/platform/ios/TestExpectations
LayoutTests/platform/mac-wk1/TestExpectations
LayoutTests/platform/mac/TestExpectations
LayoutTests/platform/win/TestExpectations
LayoutTests/platform/wincairo/TestExpectations
LayoutTests/platform/wpe/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/Modules/webgpu/GPUCanvasContext.cpp
Source/WebCore/Modules/webgpu/GPUCanvasContext.h
Source/WebCore/Modules/webgpu/GPUCanvasContext.idl
Source/WebCore/testing/InternalSettings.cpp
Source/WebCore/testing/InternalSettings.h
Source/WebCore/testing/InternalSettings.idl

index 080769f..a50721b 100644 (file)
@@ -1,3 +1,44 @@
+2019-04-02  Devin Rousso  <drousso@apple.com>
+
+        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  <cdumez@apple.com>
 
         [WK2] Add support for Window's beforeprint / afterprint events
 2019-04-02  Chris Dumez  <cdumez@apple.com>
 
         [WK2] Add support for Window's beforeprint / afterprint events
index 0e8c224..ba595b5 100644 (file)
@@ -19,7 +19,7 @@ PASS: Removed canvas has expected ID.
 -- Running test case: Canvas.CreateContext2D.Detached
 PASS: Canvas context should be 2D.
   0: getContext - [native code]
 -- 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]
   2: Global Code - [program code]
   3: evaluateWithScopeExtension - [native code]
   4: (anonymous function) - [native code]
@@ -31,7 +31,7 @@ PASS: Removed canvas has expected ID.
 Create CSS canvas from -webkit-canvas(css-canvas).
 PASS: Canvas context should be 2D.
   0: getCSSCanvasContext - [native code]
 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]
   2: Global Code - [program code]
   3: evaluateWithScopeExtension - [native code]
   4: (anonymous function) - [native code]
index d51914b..1f43e38 100644 (file)
@@ -6,21 +6,21 @@
 <script src="resources/create-context-utilities.js"></script>
 <script>
 function test() {
 <script src="resources/create-context-utilities.js"></script>
 <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,
     });
 
         name: "Attached",
         expression: `createAttachedCanvas("2d")`,
         contextType: WI.Canvas.ContextType.Canvas2D,
     });
 
-    addSimpleTestCase({
+    InspectorTest.CreateContextUtilities.addSimpleTestCase({
         name: "Detached",
         expression: `createDetachedCanvas("2d")`,
         contextType: WI.Canvas.ContextType.Canvas2D,
     });
 
         name: "Detached",
         expression: `createDetachedCanvas("2d")`,
         contextType: WI.Canvas.ContextType.Canvas2D,
     });
 
-    addCSSCanvasTestCase(WI.Canvas.ContextType.Canvas2D);
+    InspectorTest.CreateContextUtilities.addCSSCanvasTestCase(WI.Canvas.ContextType.Canvas2D);
 
     suite.runTestCasesAndFinish();
 }
 
     suite.runTestCasesAndFinish();
 }
index 33d8a86..b2b757c 100644 (file)
@@ -19,7 +19,7 @@ PASS: Removed canvas has expected ID.
 -- Running test case: Canvas.CreateContextBitmapRenderer.Detached
 PASS: Canvas context should be Bitmap Renderer.
   0: getContext - [native code]
 -- 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]
   2: Global Code - [program code]
   3: evaluateWithScopeExtension - [native code]
   4: (anonymous function) - [native code]
index 740b84d..1dac3de 100644 (file)
@@ -6,15 +6,15 @@
 <script src="resources/create-context-utilities.js"></script>
 <script>
 function test() {
 <script src="resources/create-context-utilities.js"></script>
 <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,
     });
 
         name: "Attached",
         expression: `createAttachedCanvas("bitmaprenderer")`,
         contextType: WI.Canvas.ContextType.BitmapRenderer,
     });
 
-    addSimpleTestCase({
+    InspectorTest.CreateContextUtilities.addSimpleTestCase({
         name: "Detached",
         expression: `createDetachedCanvas("bitmaprenderer")`,
         contextType: WI.Canvas.ContextType.BitmapRenderer,
         name: "Detached",
         expression: `createDetachedCanvas("bitmaprenderer")`,
         contextType: WI.Canvas.ContextType.BitmapRenderer,
index b84c311..f420e74 100644 (file)
@@ -19,7 +19,7 @@ PASS: Removed canvas has expected ID.
 -- Running test case: Canvas.CreateContextWebGL.Detached
 PASS: Canvas context should be WebGL.
   0: getContext - [native code]
 -- 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]
   2: Global Code - [program code]
   3: evaluateWithScopeExtension - [native code]
   4: (anonymous function) - [native code]
@@ -31,7 +31,7 @@ PASS: Removed canvas has expected ID.
 Create CSS canvas from -webkit-canvas(css-canvas).
 PASS: Canvas context should be WebGL.
   0: getCSSCanvasContext - [native code]
 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]
   2: Global Code - [program code]
   3: evaluateWithScopeExtension - [native code]
   4: (anonymous function) - [native code]
index 2bd5d74..760cb9a 100644 (file)
@@ -6,21 +6,21 @@
 <script src="resources/create-context-utilities.js"></script>
 <script>
 function test() {
 <script src="resources/create-context-utilities.js"></script>
 <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,
     });
 
         name: "Attached",
         expression: `createAttachedCanvas("webgl")`,
         contextType: WI.Canvas.ContextType.WebGL,
     });
 
-    addSimpleTestCase({
+    InspectorTest.CreateContextUtilities.addSimpleTestCase({
         name: "Detached",
         expression: `createDetachedCanvas("webgl")`,
         contextType: WI.Canvas.ContextType.WebGL,
     });
 
         name: "Detached",
         expression: `createDetachedCanvas("webgl")`,
         contextType: WI.Canvas.ContextType.WebGL,
     });
 
-    addCSSCanvasTestCase(WI.Canvas.ContextType.WebGL);
+    InspectorTest.CreateContextUtilities.addCSSCanvasTestCase(WI.Canvas.ContextType.WebGL);
 
     suite.runTestCasesAndFinish();
 }
 
     suite.runTestCasesAndFinish();
 }
index a3d700b..a1fddc8 100644 (file)
@@ -19,7 +19,7 @@ PASS: Removed canvas has expected ID.
 -- Running test case: Canvas.CreateContextWebGL2.Detached
 PASS: Canvas context should be WebGL2.
   0: getContext - [native code]
 -- 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]
   2: Global Code - [program code]
   3: evaluateWithScopeExtension - [native code]
   4: (anonymous function) - [native code]
@@ -31,7 +31,7 @@ PASS: Removed canvas has expected ID.
 Create CSS canvas from -webkit-canvas(css-canvas).
 PASS: Canvas context should be WebGL2.
   0: getCSSCanvasContext - [native code]
 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]
   2: Global Code - [program code]
   3: evaluateWithScopeExtension - [native code]
   4: (anonymous function) - [native code]
index e1ec7cc..905ec94 100644 (file)
@@ -9,21 +9,21 @@ if (window.internals)
     window.internals.settings.setWebGL2Enabled(true);
 
 function test() {
     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,
     });
 
         name: "Attached",
         expression: `createAttachedCanvas("webgl2")`,
         contextType: WI.Canvas.ContextType.WebGL2,
     });
 
-    addSimpleTestCase({
+    InspectorTest.CreateContextUtilities.addSimpleTestCase({
         name: "Detached",
         expression: `createDetachedCanvas("webgl2")`,
         contextType: WI.Canvas.ContextType.WebGL2,
     });
 
         name: "Detached",
         expression: `createDetachedCanvas("webgl2")`,
         contextType: WI.Canvas.ContextType.WebGL2,
     });
 
-    addCSSCanvasTestCase(WI.Canvas.ContextType.WebGL2);
+    InspectorTest.CreateContextUtilities.addCSSCanvasTestCase(WI.Canvas.ContextType.WebGL2);
 
     suite.runTestCasesAndFinish();
 }
 
     suite.runTestCasesAndFinish();
 }
diff --git a/LayoutTests/inspector/canvas/create-context-webgpu-expected.txt b/LayoutTests/inspector/canvas/create-context-webgpu-expected.txt
new file mode 100644 (file)
index 0000000..934acc3
--- /dev/null
@@ -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.
+
diff --git a/LayoutTests/inspector/canvas/create-context-webgpu.html b/LayoutTests/inspector/canvas/create-context-webgpu.html
new file mode 100644 (file)
index 0000000..0f70cad
--- /dev/null
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="stylesheet" href="resources/create-context-utilities.css">
+<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
+<script src="resources/create-context-utilities.js"></script>
+<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>
diff --git a/LayoutTests/inspector/canvas/resolveCanvasContext-webgpu-expected.txt b/LayoutTests/inspector/canvas/resolveCanvasContext-webgpu-expected.txt
new file mode 100644 (file)
index 0000000..59eddab
--- /dev/null
@@ -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".
+
diff --git a/LayoutTests/inspector/canvas/resolveCanvasContext-webgpu.html b/LayoutTests/inspector/canvas/resolveCanvasContext-webgpu.html
new file mode 100644 (file)
index 0000000..a75d993
--- /dev/null
@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
+<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>
index 141e251..d6cc55d 100644 (file)
@@ -2,19 +2,31 @@ let contexts = [];
 
 function createAttachedCanvas(contextType) {
     let canvas = document.body.appendChild(document.createElement("canvas"));
 
 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) {
 }
 
 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) {
 }
 
 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) {
 }
 
 function destroyCanvases() {
     for (let context of contexts) {
+        if (!context)
+            continue;
+
         let canvasElement = context.canvas;
         if (canvasElement && canvasElement.parentNode)
             canvasElement.remove();
         let canvasElement = context.canvas;
         if (canvasElement && canvasElement.parentNode)
             canvasElement.remove();
@@ -68,7 +80,9 @@ TestPage.registerInitializer(() => {
         });
     }
 
         });
     }
 
-    window.initializeTestSuite = function(name) {
+    InspectorTest.CreateContextUtilities = {};
+
+    InspectorTest.CreateContextUtilities.initializeTestSuite = function(name) {
         suite = InspectorTest.createAsyncSuite(name);
 
         suite.addTestCase({
         suite = InspectorTest.createAsyncSuite(name);
 
         suite.addTestCase({
@@ -83,7 +97,7 @@ TestPage.registerInitializer(() => {
         return suite;
     };
 
         return suite;
     };
 
-    window.addSimpleTestCase = function({name, description, expression, contextType}) {
+    InspectorTest.CreateContextUtilities.addSimpleTestCase = function({name, description, expression, contextType}) {
         suite.addTestCase({
             name: suite.name + "." + name,
             description,
         suite.addTestCase({
             name: suite.name + "." + name,
             description,
@@ -108,7 +122,7 @@ TestPage.registerInitializer(() => {
     };
 
     let previousCSSCanvasContextType = null;
     };
 
     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;
         InspectorTest.assert(!previousCSSCanvasContextType || previousCSSCanvasContextType === contextType, "addCSSCanvasTestCase cannot be called more than once with different context types.");
         if (!previousCSSCanvasContextType)
             previousCSSCanvasContextType = contextType;
@@ -123,7 +137,14 @@ TestPage.registerInitializer(() => {
                 })
                 .then(resolve, reject);
 
                 })
                 .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")`);
             },
                 InspectorTest.log(`Create CSS canvas from -webkit-canvas(css-canvas).`);
                 InspectorTest.evaluateInPage(`createCSSCanvas("${contextId}", "css-canvas")`);
             },
index b19fb15..8bc8132 100644 (file)
@@ -1236,6 +1236,8 @@ webkit.org/b/168466 http/tests/security/bypassing-cors-checks-for-extension-urls
 
 # No support for WebGPU yet
 webkit.org/b/191005 webgpu/ [ Skip ]
 
 # 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 ]
 
 # No support for resource load statistics yet
 http/tests/resourceLoadStatistics/ [ Skip ]
index 6bb43b6..7ba15b3 100644 (file)
@@ -41,6 +41,8 @@ compositing/no-compositing-when-fulll-screen-is-present.html
 
 # WebGPU is not enabled on iOS Simulator.
 webgpu [ Skip ]
 
 # 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/
 
 # Encrypted Media Extensions are not enabled
 media/encrypted-media/
index 37ed071..5ae5a16 100644 (file)
@@ -43,7 +43,10 @@ imported/w3c/web-platform-tests/css/css-properties-values-api/ [ Skip ]
 css-custom-properties-api [ Skip ]
 css-typedom [ Skip ]
 css-dark-mode [ Skip ]
 css-custom-properties-api [ Skip ]
 css-typedom [ Skip ]
 css-dark-mode [ Skip ]
+
 webgpu [ 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
 
 # Media Stream API testing is not supported for WK1 yet.
 fast/mediastream
index 56cc486..067ff4b 100644 (file)
@@ -1779,6 +1779,8 @@ webkit.org/b/190892 [ Debug ] webgl/2.0.0/conformance2/textures/misc/tex-unpack-
 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/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 ]
 
 
 webkit.org/b/189680 platform/mac/media/audio-session-category-video-paused.html [ Pass Timeout ]
 
index c48bf1f..051ead9 100644 (file)
@@ -4217,6 +4217,8 @@ webkit.org/b/190520 editing/pasteboard/copy-paste-across-shadow-boundaries-with-
 
 # WebGPU is not supported on Windows
 webgpu [ Skip ]
 
 # 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 ]
 
 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 ]
index 95ddd30..1a8aadd 100644 (file)
@@ -291,6 +291,8 @@ webgl/webgl2-rendering-context-obtain.html [ Skip ]
 
 # WEBGPU is disabled
 webgpu [ Skip ]
 
 # 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 ]
 
 # WIRELESS_PLAYBACK_TARGET is disabled
 media/airplay-target-availability.html [ Skip ]
index e1ad108..f21e693 100644 (file)
@@ -295,6 +295,8 @@ Bug(WPE) js/stringimpl-to-jsstring-on-large-strings-3.html [ Skip ]
 
 # No WebGPU support yet
 webgpu [ Skip ]
 
 # 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 ]
 
 # 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 ]
index 7ade8ac..44973a6 100644 (file)
@@ -1,3 +1,25 @@
+2019-04-02  Devin Rousso  <drousso@apple.com>
+
+        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  <cdumez@apple.com>
 
         [WK2] Add support for Window's beforeprint / afterprint events
 2019-04-02  Chris Dumez  <cdumez@apple.com>
 
         [WK2] Add support for Window's beforeprint / afterprint events
index 68f09d1..79e65c9 100644 (file)
@@ -26,6 +26,8 @@
 #include "config.h"
 #include "GPUCanvasContext.h"
 
 #include "config.h"
 #include "GPUCanvasContext.h"
 
+#include "InspectorInstrumentation.h"
+
 #if ENABLE(WEBGPU)
 
 namespace WebCore {
 #if ENABLE(WEBGPU)
 
 namespace WebCore {
@@ -34,6 +36,9 @@ std::unique_ptr<GPUCanvasContext> GPUCanvasContext::create(CanvasBase& canvas)
 {
     auto context = std::unique_ptr<GPUCanvasContext>(new GPUCanvasContext(canvas));
     context->suspendIfNeeded();
 {
     auto context = std::unique_ptr<GPUCanvasContext>(new GPUCanvasContext(canvas));
     context->suspendIfNeeded();
+
+    InspectorInstrumentation::didCreateCanvasRenderingContext(*context);
+
     return context;
 }
 
     return context;
 }
 
index e65476b..61c9aa2 100644 (file)
@@ -28,6 +28,7 @@
 #if ENABLE(WEBGPU)
 
 #include "GPUBasedCanvasRenderingContext.h"
 #if ENABLE(WEBGPU)
 
 #include "GPUBasedCanvasRenderingContext.h"
+#include "HTMLCanvasElement.h"
 #include "WebGPUSwapChain.h"
 #include <wtf/RefPtr.h>
 
 #include "WebGPUSwapChain.h"
 #include <wtf/RefPtr.h>
 
@@ -37,6 +38,8 @@ class GPUCanvasContext final : public GPUBasedCanvasRenderingContext {
 public:
     static std::unique_ptr<GPUCanvasContext> create(CanvasBase&);
 
 public:
     static std::unique_ptr<GPUCanvasContext> create(CanvasBase&);
 
+    HTMLCanvasElement& canvas() const { return downcast<HTMLCanvasElement>(canvasBase()); }
+
     void replaceSwapChain(Ref<WebGPUSwapChain>&&);
 
 private:
     void replaceSwapChain(Ref<WebGPUSwapChain>&&);
 
 private:
index 09531f6..47c70ff 100644 (file)
@@ -28,4 +28,6 @@
     Conditional=WEBGPU,
     EnabledAtRuntime=WebGPU
 ] interface GPUCanvasContext {
     Conditional=WEBGPU,
     EnabledAtRuntime=WebGPU
 ] interface GPUCanvasContext {
+    // back-reference to the canvas
+    readonly attribute HTMLCanvasElement canvas;
 };
 };
index c877dd5..ce34c0f 100644 (file)
@@ -758,6 +758,15 @@ void InternalSettings::setWebGL2Enabled(bool enabled)
 #endif
 }
 
 #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);
 void InternalSettings::setWebVREnabled(bool enabled)
 {
     RuntimeEnabledFeatures::sharedFeatures().setWebVREnabled(enabled);
index f96f8c6..b6fc3c9 100644 (file)
@@ -123,6 +123,7 @@ public:
     // RuntimeEnabledFeatures.
     static void setIndexedDBWorkersEnabled(bool);
     static void setWebGL2Enabled(bool);
     // RuntimeEnabledFeatures.
     static void setIndexedDBWorkersEnabled(bool);
     static void setWebGL2Enabled(bool);
+    static void setWebGPUEnabled(bool);
     static void setWebVREnabled(bool);
     static void setScreenCaptureEnabled(bool);
 
     static void setWebVREnabled(bool);
     static void setScreenCaptureEnabled(bool);
 
index 5fd09ca..2d0e646 100644 (file)
@@ -91,6 +91,7 @@ enum FontLoadTimingOverride { "Block", "Swap", "Failure" };
     // RuntimeEnabledFeatures.
     void setIndexedDBWorkersEnabled(boolean enabled);
     void setWebGL2Enabled(boolean enabled);
     // RuntimeEnabledFeatures.
     void setIndexedDBWorkersEnabled(boolean enabled);
     void setWebGL2Enabled(boolean enabled);
+    void setWebGPUEnabled(boolean enabled);
     void setWebVREnabled(boolean enabled);
     void setScreenCaptureEnabled(boolean enabled);
 
     void setWebVREnabled(boolean enabled);
     void setScreenCaptureEnabled(boolean enabled);