Fix broken paths in `NativeFunctions.js` generator

`scripts/javascript_natives/index.js` expects `NativeFunctions.js` to
reside at a specific path, and broke when a CL [1] moved it to another
location, and broke (in another way) when the DevTools front-end
codebase moved to a separate repository. Similarly, the script expects
a Chromium checkout at a specific location relative to itself, which
hasn’t been correct since the DevTools front-end codebase moved to a
separate repository.

This patch updates the expected locations, but does not re-generate
the output since the script requires additional follow-up fixes.

[1]: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2814662

Bug: chromium:1255619
Change-Id: I066fb4349f045df5a12edd1378d7acdaa733a61b
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3201677
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
Commit-Queue: Mathias Bynens <mathias@chromium.org>
diff --git a/scripts/javascript_natives/index.js b/scripts/javascript_natives/index.js
index 3c87be4..4bbfd9a 100644
--- a/scripts/javascript_natives/index.js
+++ b/scripts/javascript_natives/index.js
@@ -51,28 +51,33 @@
   storeMethod(node.name.text, func.name.escapedText, args);
 }
 
-glob('../../../../blink/renderer/+(core|modules)/**/*.idl', {cwd: process.env.PWD}, function(er, files) {
-  for (const file of files) {
-    if (file.includes('testing')) {
-      continue;
-    }
-    const data = fs.readFileSync(path.join(process.env.PWD, file), 'utf8');
-    const lines = data.split('\n');
-    const newLines = [];
-    for (line of lines) {
-      if (!line.includes(' attribute ')) {
-        newLines.push(line);
-      }
-    }
+// Assume the DevTools front-end repository is at
+// `devtools/devtools-frontend`, where `devtools` is on the same level
+// as `chromium`. This matches `scripts/npm_test.js`.
+glob(
+    '../../../../chromium/src/third_party/blink/renderer/+(core|modules)/**/*.idl', {cwd: process.env.PWD},
+    function(er, files) {
+      for (const file of files) {
+        if (file.includes('testing')) {
+          continue;
+        }
+        const data = fs.readFileSync(path.join(process.env.PWD, file), 'utf8');
+        const lines = data.split('\n');
+        const newLines = [];
+        for (const line of lines) {
+          if (!line.includes(' attribute ')) {
+            newLines.push(line);
+          }
+        }
 
-    try {
-      WebIDL2.parse(newLines.join('\n')).forEach(walk);
-    } catch (e) {
-      // console.error(file);
-    }
-  }
-  WebIDL2
-      .parse(`
+        try {
+          WebIDL2.parse(newLines.join('\n')).forEach(walk);
+        } catch (e) {
+          // console.error(file);
+        }
+      }
+      WebIDL2
+          .parse(`
   namespace console {
     void assert(optional boolean condition = false, any... data);
     void clear();
@@ -96,8 +101,8 @@
     void warn(any... data);
   };
 `).forEach(walk);
-  postProcess();
-});
+      postProcess();
+    });
 
 function walk(thing, parent) {
   if (thing.type === 'interface') {
@@ -215,11 +220,12 @@
   }
 
   fs.writeFileSync(
-      path.join(__dirname, '..', '..', 'front_end', 'javascript_metadata', 'NativeFunctions.js'),
+      path.join(__dirname, '..', '..', 'front_end', 'models', 'javascript_metadata', 'NativeFunctions.js'),
       `// Copyright 2020 The Chromium Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 // Generated from ${path.relative(path.join(__dirname, '..', '..'), __filename)}
-export const NativeFunctions = ${JSON.stringify(functions)};
+
+export const NativeFunctions = ${JSON.stringify(functions, null, 2)};
 `);
 }