diff --git a/utils/build_patcher.js b/utils/build_patcher.js new file mode 100644 index 0000000000000..f030fd65174b7 --- /dev/null +++ b/utils/build_patcher.js @@ -0,0 +1,29 @@ +const fs = require('fs'); + +function patch_driver(path){ + console.log("Patching driver for " + path) + + function commentRuntimeEnable(path){ + fileText = fs.readFileSync(path, 'utf8') + const regex = new RegExp(".*Runtime\.enable.*", "g"); + const matchedRegex = fileText.match(regex) + for(const target of matchedRegex){ + fileText = fileText.replace(target, "// " + target); + } + fs.writeFileSync(path,fileText) + return true + } + + // comment occurencies of Runtime.Enable + const filesToPatch = ["crDevTools.ts", "crPage.ts","crServiceWorker.ts"] + for( file of filesToPatch){ + if(commentRuntimeEnable(path + "chromium/" + file)){ + console.log("Succesfully patched " + file) + } + } + + // patching execution context + frames_path = path + "frames.js" +} + +patch_driver('../packages/playwright-core/src/server/') \ No newline at end of file