MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / injectProbeScript

Function injectProbeScript

scripts/run-javascript-lifecycle-tests.mjs:138–152  ·  view source on GitHub ↗

* Inject the harness server's log-capture probe (the same shim * ``run-javascript-browser-tests.sh`` uses for the screenshot * suite) into ``index.html``. Without it, console output never * makes it into ``browser.log`` — Playwright still sees the * messages directly via ``page.on('console')`` s

(indexHtml)

Source from the content-addressed store, hash-verified

136 * report has nothing for a CI consumer to grep through.
137 */
138function injectProbeScript(indexHtml) {
139 if (!fs.existsSync(indexHtml)) return;
140 let text = fs.readFileSync(indexHtml, 'utf8');
141 const probe = '<script src="/__cn1__/probe.js"></script>';
142 if (text.indexOf(probe) >= 0) return;
143 const bridge = '<script src="browser_bridge.js"></script>';
144 if (text.indexOf(bridge) >= 0) {
145 text = text.replace(bridge, probe + '\n' + bridge);
146 } else if (text.indexOf('</body>') >= 0) {
147 text = text.replace('</body>', probe + '\n</body>');
148 } else {
149 text += '\n' + probe + '\n';
150 }
151 fs.writeFileSync(indexHtml, text, 'utf8');
152}
153
154/**
155 * Walk into the bundle directory and return the directory containing

Callers 1

runBundleFunction · 0.85

Calls 2

indexOfMethod · 0.65
replaceMethod · 0.65

Tested by

no test coverage detected