Add SurfaceDescriptorFromHTMLCanvasID

Bug:dawn:269

Change-Id: I91802b44d0280224b93eb4fb637e91597bc03c81
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/15322
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
diff --git a/dawn.json b/dawn.json
index 0038087..6942304 100644
--- a/dawn.json
+++ b/dawn.json
@@ -1296,6 +1296,13 @@
             {"name": "label", "type": "char", "annotation": "const*", "length": "strlen", "optional": true}
         ]
     },
+    "surface descriptor from HTML canvas id": {
+        "category": "structure",
+        "chained": true,
+        "members": [
+            {"name": "id", "type": "char", "annotation": "const*", "length": "strlen"}
+        ]
+    },
     "surface descriptor from metal layer": {
         "category": "structure",
         "chained": true,
@@ -1349,7 +1356,8 @@
             {"value": 0, "name": "invalid"},
             {"value": 1, "name": "surface descriptor from metal layer"},
             {"value": 2, "name": "surface descriptor from windows HWND"},
-            {"value": 3, "name": "surface descriptor from xlib"}
+            {"value": 3, "name": "surface descriptor from xlib"},
+            {"value": 4, "name": "surface descriptor from HTML canvas id"}
         ]
     },
     "texture": {
diff --git a/src/dawn_native/Surface.cpp b/src/dawn_native/Surface.cpp
index 0d02144..fa90d78 100644
--- a/src/dawn_native/Surface.cpp
+++ b/src/dawn_native/Surface.cpp
@@ -95,6 +95,7 @@
             } break;
 #endif  // defined(DAWN_USE_X11)
 
+            case wgpu::SType::SurfaceDescriptorFromHTMLCanvasId:
             default:
                 return DAWN_VALIDATION_ERROR("Unsupported sType");
         }
diff --git a/src/tests/end2end/WindowSurfaceTests.cpp b/src/tests/end2end/WindowSurfaceTests.cpp
index 779622e..d883d20 100644
--- a/src/tests/end2end/WindowSurfaceTests.cpp
+++ b/src/tests/end2end/WindowSurfaceTests.cpp
@@ -110,6 +110,17 @@
     AssertSurfaceCreation(&descriptor, false);
 }
 
+// Test that a chained descriptor with HTMLCanvas produces an error.
+TEST_F(WindowSurfaceInstanceTests, HTMLCanvasDescriptor) {
+    wgpu::SurfaceDescriptorFromHTMLCanvasId chainedDescriptor;
+    chainedDescriptor.id = "myCanvas";
+
+    wgpu::SurfaceDescriptor descriptor;
+    descriptor.nextInChain = &chainedDescriptor;
+
+    AssertSurfaceCreation(&descriptor, false);
+}
+
 // Test that it is invalid to give two valid chained descriptors
 TEST_F(WindowSurfaceInstanceTests, TwoChainedDescriptors) {
     GLFWwindow* window = CreateWindow();