Include typedefs as idlharness dependencies (#18006)

* Include typedefs as dependencies

* Fix credential-management

* Add FileAPI dep to html/dom interfaces test
diff --git a/credential-management/idlharness.https.window.js b/credential-management/idlharness.https.window.js
index 15508b8..789643e 100644
--- a/credential-management/idlharness.https.window.js
+++ b/credential-management/idlharness.https.window.js
@@ -5,31 +5,32 @@
 
 'use strict';
 
-promise_test(async () => {
-  const idl = await fetch('/interfaces/credential-management.idl').then(r => r.text());
-  const html = await fetch('/interfaces/html.idl').then(r => r.text());
+idl_test(
+  ['credential-management'],
+  ['html', 'dom'],
+  idl_array => {
+    idl_array.add_objects({
+      CredentialsContainer: ['navigator.credentials'],
+      PasswordCredential: ['passwordCredential'],
+      FederatedCredential: ['federatedCredential'],
+    });
 
-  var idl_array = new IdlArray();
-  idl_array.add_idls(idl);
-  idl_array.add_dependency_idls(html);
-  idl_array.add_objects({
-    CredentialsContainer: ['navigator.credentials'],
-    PasswordCredential: [
-      `new PasswordCredential({
+    try {
+      self.passwordCredential = new PasswordCredential({
         id: "id",
         password: "pencil",
         iconURL: "https://example.com/",
         name: "name"
-      })`
-    ],
-    FederatedCredential: [
-      `new FederatedCredential({
+      });
+    } catch (e) {}
+
+    try {
+      self.federatedCredential = new FederatedCredential({
         id: "id",
         provider: "https://example.com",
         iconURL: "https://example.com/",
         name: "name"
-      })`
-    ]
-  });
-  idl_array.test();
-})
+      });
+    } catch (e) {}
+  }
+)
diff --git a/html/dom/interfaces.https.html b/html/dom/interfaces.https.html
index 433d802..7745e4c 100644
--- a/html/dom/interfaces.https.html
+++ b/html/dom/interfaces.https.html
@@ -38,7 +38,7 @@
 
 idl_test(
   ['html'],
-  ['SVG', 'cssom', 'touch-events', 'uievents', 'dom', 'xhr'],
+  ['SVG', 'cssom', 'touch-events', 'uievents', 'dom', 'xhr', 'FileAPI'],
   async idlArray => {
     self.documentWithHandlers = new Document();
     const handler = function(e) {};
diff --git a/resources/idlharness.js b/resources/idlharness.js
index 056540a..e7a3abb 100644
--- a/resources/idlharness.js
+++ b/resources/idlharness.js
@@ -251,6 +251,15 @@
         this.includes[k].forEach(v => all_deps.add(v));
     });
     this.partials.forEach(p => all_deps.add(p.name));
+    // Add 'TypeOfType' for each "typedef TypeOfType MyType;" entry.
+    Object.entries(this.members).forEach(([k, v]) => {
+        if (v instanceof IdlTypedef) {
+            let defs = v.idlType.union
+                ? v.idlType.idlType.map(t => t.idlType)
+                : [v.idlType.idlType];
+            defs.forEach(d => all_deps.add(d));
+        }
+    });
 
     // Add the attribute idlTypes of all the nested members of idls.
     const attrDeps = parsedIdls => {