[web] Fix dart:mirrors and include it with the dart2js SDK so we ensure it doesn't break accidentally

Change-Id: I047136bb5d09680be38408de9581cf6931e516d1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152406
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
diff --git a/sdk/lib/_internal/js_runtime/lib/mirrors_patch_cfe.dart b/sdk/lib/_internal/js_runtime/lib/mirrors_patch_cfe.dart
index cd961a0..c429ecb 100644
--- a/sdk/lib/_internal/js_runtime/lib/mirrors_patch_cfe.dart
+++ b/sdk/lib/_internal/js_runtime/lib/mirrors_patch_cfe.dart
@@ -20,17 +20,11 @@
 ClassMirror reflectClass(Type key) => throw new UnsupportedError(_message);
 
 @patch
-TypeMirror reflectType(Type key, [List<Type> typeArguments]) =>
+TypeMirror reflectType(Type key, [List<Type>? typeArguments]) =>
     throw new UnsupportedError(_message);
 
 @patch
 abstract class MirrorSystem {
-  Map<Uri, LibraryMirror> get libraries;
-  IsolateMirror get isolate;
-  TypeMirror get dynamicType;
-  TypeMirror get voidType;
-  TypeMirror get neverType;
-
   @patch
   LibraryMirror findLibrary(Symbol libraryName) =>
       throw new UnsupportedError(_message);
@@ -39,6 +33,6 @@
   static String getName(Symbol symbol) => throw new UnsupportedError(_message);
 
   @patch
-  static Symbol getSymbol(String name, [LibraryMirror library]) =>
+  static Symbol getSymbol(String name, [LibraryMirror? library]) =>
       throw new UnsupportedError(_message);
 }
diff --git a/tests/lib/lib.status b/tests/lib/lib.status
index 9b87a8d..87f57d3 100644
--- a/tests/lib/lib.status
+++ b/tests/lib/lib.status
@@ -38,6 +38,9 @@
 js/instanceof_test: SkipByDesign # Issue 42085. CSP policy disallows injected JS code
 js/parameters_test: SkipByDesign # Issue 42085.
 
+[ $compiler != dart2js && $compiler != dartdevk ]
+web/*: SkipByDesign
+
 [ $runtime == chrome && $system == linux ]
 mirrors/native_class_test: Slow, Pass
 
diff --git a/tests/lib/web/mirrors_support_test.dart b/tests/lib/web/mirrors_support_test.dart
new file mode 100644
index 0000000..03dc2d5
--- /dev/null
+++ b/tests/lib/web/mirrors_support_test.dart
@@ -0,0 +1,17 @@
+// Copyright (c) 2020, the Dart project authors.  Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// 'dart:mirrors' provides no functionality in dart-web, but can be imported and
+// all APIs throw.
+import 'dart:mirrors';
+import 'package:expect/expect.dart';
+
+main() {
+  Expect.throws<UnsupportedError>(() => currentMirrorSystem());
+  Expect.throws<UnsupportedError>(() => reflect(main));
+  Expect.throws<UnsupportedError>(() => reflectClass(Object));
+  Expect.throws<UnsupportedError>(() => reflectType(Object));
+  Expect.throws<UnsupportedError>(() => MirrorSystem.getName(#core));
+  Expect.throws<UnsupportedError>(() => MirrorSystem.getSymbol("core"));
+}
diff --git a/tests/lib_2/lib_2.status b/tests/lib_2/lib_2.status
index 5a05b95..d17a636 100644
--- a/tests/lib_2/lib_2.status
+++ b/tests/lib_2/lib_2.status
@@ -38,6 +38,9 @@
 js/instanceof_test: SkipByDesign # Issue 42085. CSP policy disallows injected JS code
 js/parameters_test: SkipByDesign # Issue 42085.
 
+[ $compiler != dart2js && $compiler != dartdevk ]
+web/*: SkipByDesign
+
 [ $runtime == chrome && $system == linux ]
 mirrors/native_class_test: Slow, Pass
 
diff --git a/tests/lib_2/web/mirrors_support_test.dart b/tests/lib_2/web/mirrors_support_test.dart
new file mode 100644
index 0000000..03dc2d5
--- /dev/null
+++ b/tests/lib_2/web/mirrors_support_test.dart
@@ -0,0 +1,17 @@
+// Copyright (c) 2020, the Dart project authors.  Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// 'dart:mirrors' provides no functionality in dart-web, but can be imported and
+// all APIs throw.
+import 'dart:mirrors';
+import 'package:expect/expect.dart';
+
+main() {
+  Expect.throws<UnsupportedError>(() => currentMirrorSystem());
+  Expect.throws<UnsupportedError>(() => reflect(main));
+  Expect.throws<UnsupportedError>(() => reflectClass(Object));
+  Expect.throws<UnsupportedError>(() => reflectType(Object));
+  Expect.throws<UnsupportedError>(() => MirrorSystem.getName(#core));
+  Expect.throws<UnsupportedError>(() => MirrorSystem.getSymbol("core"));
+}