Repository: microsoft/vscode-edge-devtools
Pull request #107 (2019-11-14 20:17:36)

Fixing issues caused by chromium devtools repository migration.
Chromium repository migrated to a new repository and a new path, this PR address the following issues caused by this:

- Fixes the path for devtools folder and updates postBuildStep with the new path.
- Fixes an issue caused by moving window.Runtime to window.Root.Runtime
- Fixes an issue caused by session storage not being available for the developer tools as VsCode does not exposes it
- Fixes associated tests


Patch:
diff --git a/postBuildStep.ts b/postBuildStep.ts
index 57094b9..ec98808 100644
--- a/postBuildStep.ts
+++ b/postBuildStep.ts
@@ -40,7 +40,7 @@ async function copyStaticFiles() {
     // See CONTRIBUTING.md for more details
 
     const toolsSrcDir =
-        `${process.env.EDGE_CHROMIUM_PATH}/third_party/blink/renderer/devtools/front_end/`;
+        `${process.env.EDGE_CHROMIUM_PATH}/third_party/devtools-frontend/src/front_end/`;
     if (!isDirectory(toolsSrcDir)) {
         throw new Error(`Could not find Microsoft Edge (Chromium) DevTools path at '${toolsSrcDir}'. ` +
             "Did you set the EDGE_CHROMIUM_PATH environment variable?");
diff --git a/src/host/host.ts b/src/host/host.ts
index fb1d0cc..3a0c152 100644
--- a/src/host/host.ts
+++ b/src/host/host.ts
@@ -9,6 +9,10 @@ import ToolsWebSocket from "./toolsWebSocket";
 export interface IDevToolsWindow extends Window {
     InspectorFrontendHost: ToolsHost;
     WebSocket: typeof ToolsWebSocket;
+    Root: IRoot;
+}
+
+export interface IRoot {
     Runtime: IRuntimeResourceLoader;
 }
 
@@ -25,6 +29,13 @@ export function initialize(devToolsFrame: HTMLIFrameElement) {
         set() { /* NO-OP */ },
     });
 
+    // Create a mock sessionStorage since it doesn't exist in data url but the devtools use it
+    const sessionStorage = {};
+    Object.defineProperty(dtWindow, "sessionStorage", {
+        get() { return sessionStorage; },
+        set() { /* NO-OP */ },
+    });
+
     // Setup the global objects that must exist at load time
     dtWindow.InspectorFrontendHost = new ToolsHost();
     dtWindow.WebSocket = ToolsWebSocket;
@@ -41,7 +52,7 @@ export function initialize(devToolsFrame: HTMLIFrameElement) {
 
     dtWindow.addEventListener("DOMContentLoaded", () => {
         // Override the resource loading once the window has loaded so that we can control it
-        const resourceLoader = ToolsResourceLoader.overrideResourceLoading(dtWindow.Runtime);
+        const resourceLoader = ToolsResourceLoader.overrideResourceLoading(dtWindow.Root.Runtime);
         dtWindow.InspectorFrontendHost.setResourceLoader(resourceLoader);
     });
 }


Test patch:
diff --git a/src/host/host.test.ts b/src/host/host.test.ts
index d01a27f..fa105e4 100644
--- a/src/host/host.test.ts
+++ b/src/host/host.test.ts
@@ -15,6 +15,7 @@ describe("host", () => {
 
         mockIframe = {
             contentWindow: {
+                Root: {},
                 addEventListener: jest.fn(),
                 localStorage: jest.fn(),
             } as object,
@@ -59,6 +60,18 @@ describe("host", () => {
             setter!.set!("some new value");
             expect(mockDevToolsWindow.localStorage).toBeUndefined();
         });
+
+        it("emulates session storage", async () => {
+            const host = await import("./host");
+            host.initialize(mockIframe);
+
+            expect(mockDevToolsWindow.sessionStorage).toBeDefined();
+
+            const expectedKey = "key";
+            const expectedVal = "value";
+            (mockDevToolsWindow as any).sessionStorage[expectedKey] = expectedVal;
+            expect(mockDevToolsWindow.sessionStorage[expectedKey]).toEqual(expectedVal);
+        });
     });
 
     describe("DOMContentLoaded", () => {