diff --git a/lighthouse-core/scripts/build-traceviewer-module.js b/lighthouse-core/scripts/build-traceviewer-module.js index 4076d20a02ae..92d988affcc0 100644 --- a/lighthouse-core/scripts/build-traceviewer-module.js +++ b/lighthouse-core/scripts/build-traceviewer-module.js @@ -70,6 +70,8 @@ function convertImport(src) { // node4 compat scriptsContent = polyfillNode4Support(dest, scriptsContent); + // browser compat + scriptsContent = adjustForBrowserCompat(scriptsContent); writeNewFile(dest, scriptsContent); @@ -133,6 +135,12 @@ function convertImport(src) { return transformed; } + function adjustForBrowserCompat(scriptsContent) { + return scriptsContent + // early exit in tracing/base.ui and avoid currentScript from breaking us. + .replace('var THIS_DOC = document.currentScript.ownerDocument;', 'return;'); + } + function writeNewFile(dest, scriptsContent) { dest = dest.replace('./third_party/src/catapult/tracing/tracing/', ''); dest = path.resolve('./third_party/traceviewer-js/' + dest); diff --git a/lighthouse-core/third_party/traceviewer-js/ui/base/overlay.js b/lighthouse-core/third_party/traceviewer-js/ui/base/overlay.js index 2320ad6be8d0..0a92b205859f 100644 --- a/lighthouse-core/third_party/traceviewer-js/ui/base/overlay.js +++ b/lighthouse-core/third_party/traceviewer-js/ui/base/overlay.js @@ -24,7 +24,7 @@ require("./utils.js"); global.tr.exportTo('tr.ui.b', function () { if (tr.isHeadless) return {}; - var THIS_DOC = document.currentScript.ownerDocument; + return; /** * Creates a new overlay element. It will not be visible until shown.