@empiricalrun/test-gen 0.38.15 → 0.38.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/agent/browsing/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAK3D,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAiBvD,OAAO,EAAe,aAAa,EAAE,MAAM,aAAa,CAAC;AAMzD,wBAAgB,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,MAAM,CAKhD;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,EAAE,UAIvD;AA6FD;;;;GAIG;AACH,wBAAsB,yBAAyB,CAC7C,SAAS,EAAE,aAAa,EACxB,KAAK,CAAC,EAAE,WAAW,GAClB,OAAO,CAAC,MAAM,CAAC,CA0DjB;AAyBD,wBAAsB,wBAAwB,CAAC,IAAI,EAAE,IAAI,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/agent/browsing/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAK3D,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAiBvD,OAAO,EAAe,aAAa,EAAE,MAAM,aAAa,CAAC;AAMzD,wBAAgB,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,MAAM,CAKhD;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,EAAE,UAIvD;AA6FD;;;;GAIG;AACH,wBAAsB,yBAAyB,CAC7C,SAAS,EAAE,aAAa,EACxB,KAAK,CAAC,EAAE,WAAW,GAClB,OAAO,CAAC,MAAM,CAAC,CA0DjB;AAyBD,wBAAsB,wBAAwB,CAAC,IAAI,EAAE,IAAI,iBAuHxD;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,QA+BjD;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,oBAAoB,CAAC,CAM1E;AAWD;;;;;GAKG;AACH,wBAAsB,iBAAiB,CACrC,YAAY,EAAE,MAAM,EACpB,gBAAgB,EAAE,oBAAoB,EACtC,gBAAgB,GAAE,MAAM,EAAU,GACjC,OAAO,CAAC,MAAM,CAAC,CA+CjB;AAED,wBAAsB,sBAAsB,CAAC,EAC3C,YAAiB,EACjB,IAAS,EACT,eAAoB,EACpB,gBAAqB,EACrB,UAAyC,GAC1C,EAAE;IACD,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,8EASA;AAED,qBAAa,eAAe;IACd,OAAO,CAAC,SAAS;gBAAT,SAAS,EAAE,MAAM;IACrC,OAAO,CAAC,aAAa,CAAqB;YAE5B,mBAAmB;YAUnB,gBAAgB;IAsBjB,OAAO;IAuBb,SAAS;CAKjB"}
|
|
@@ -182,6 +182,11 @@ async function injectPwLocatorGenerator(page) {
|
|
|
182
182
|
try {
|
|
183
183
|
await Promise.all(scripts.map((s) => page.addScriptTag({ content: s })));
|
|
184
184
|
await page.evaluate(async () => {
|
|
185
|
+
//@ts-ignore
|
|
186
|
+
//https://developer.mozilla.org/en-US/docs/Web/API/TrustedScriptURL
|
|
187
|
+
const trustedPolicy = window.trustedTypes?.createPolicy(crypto.randomUUID(), {
|
|
188
|
+
createScriptURL: (url) => url,
|
|
189
|
+
});
|
|
185
190
|
//@ts-ignore
|
|
186
191
|
const injectScriptInIframe = (iframeDoc) => {
|
|
187
192
|
try {
|
|
@@ -189,10 +194,9 @@ async function injectPwLocatorGenerator(page) {
|
|
|
189
194
|
"https://assets-test.empirical.run/pw-selector.js",
|
|
190
195
|
"https://code.jquery.com/jquery-3.7.1.min.js",
|
|
191
196
|
].forEach((url) => {
|
|
192
|
-
const
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
iframeDoc.head.appendChild(scr);
|
|
197
|
+
const script = iframeDoc.createElement("script");
|
|
198
|
+
script.src = trustedPolicy.createScriptURL(url);
|
|
199
|
+
iframeDoc.head.appendChild(script);
|
|
196
200
|
});
|
|
197
201
|
}
|
|
198
202
|
catch (e) {
|
|
@@ -207,7 +211,8 @@ async function injectPwLocatorGenerator(page) {
|
|
|
207
211
|
if (isVisible) {
|
|
208
212
|
//@ts-ignore
|
|
209
213
|
const iframeContent = iframe.contentDocument || iframe.contentWindow?.document;
|
|
210
|
-
|
|
214
|
+
const isScriptInjected = !!iframe.contentWindow?.playwright;
|
|
215
|
+
if (iframeContent && !isScriptInjected) {
|
|
211
216
|
injectScriptInIframe(iframeContent);
|
|
212
217
|
}
|
|
213
218
|
}
|
|
@@ -224,18 +229,22 @@ async function injectPwLocatorGenerator(page) {
|
|
|
224
229
|
//@ts-ignore
|
|
225
230
|
const injectScriptInIframe = (iframeDoc) => {
|
|
226
231
|
try {
|
|
232
|
+
//@ts-ignore
|
|
233
|
+
//https://developer.mozilla.org/en-US/docs/Web/API/TrustedScriptURL
|
|
234
|
+
const trustedPolicy = window.trustedTypes.createPolicy(crypto.randomUUID(), {
|
|
235
|
+
createScriptURL: (url) => url,
|
|
236
|
+
});
|
|
227
237
|
[
|
|
228
238
|
"https://assets-test.empirical.run/pw-selector.js",
|
|
229
239
|
"https://code.jquery.com/jquery-3.7.1.min.js",
|
|
230
240
|
].forEach((url) => {
|
|
231
241
|
const scr = iframeDoc.createElement("script");
|
|
232
|
-
scr.src = url;
|
|
233
|
-
console.log("Injecting script in iframe", scr);
|
|
242
|
+
scr.src = trustedPolicy.createScriptURL(url);
|
|
234
243
|
iframeDoc.head.appendChild(scr);
|
|
235
244
|
});
|
|
236
245
|
}
|
|
237
246
|
catch (e) {
|
|
238
|
-
console.warn("Error injecting script in iframe
|
|
247
|
+
console.warn("Error injecting script in iframe.");
|
|
239
248
|
}
|
|
240
249
|
};
|
|
241
250
|
const iframes = document.getElementsByTagName("iframe");
|
|
@@ -246,7 +255,8 @@ async function injectPwLocatorGenerator(page) {
|
|
|
246
255
|
if (isVisible) {
|
|
247
256
|
//@ts-ignore
|
|
248
257
|
const iframeContent = iframe.contentDocument || iframe.contentWindow?.document;
|
|
249
|
-
|
|
258
|
+
const isScriptInjected = !!iframe.contentWindow?.playwright;
|
|
259
|
+
if (iframeContent && !isScriptInjected) {
|
|
250
260
|
injectScriptInIframe(iframeContent);
|
|
251
261
|
}
|
|
252
262
|
}
|
|
@@ -254,7 +264,7 @@ async function injectPwLocatorGenerator(page) {
|
|
|
254
264
|
});
|
|
255
265
|
}
|
|
256
266
|
catch (e) {
|
|
257
|
-
console.warn("Error injecting script in iframe
|
|
267
|
+
console.warn("Error injecting script in iframe.");
|
|
258
268
|
}
|
|
259
269
|
}
|
|
260
270
|
exports.injectPwLocatorGenerator = injectPwLocatorGenerator;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@empiricalrun/test-gen",
|
|
3
|
-
"version": "0.38.
|
|
3
|
+
"version": "0.38.16",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org/",
|
|
6
6
|
"access": "public"
|
|
@@ -59,8 +59,8 @@
|
|
|
59
59
|
"tsx": "^4.16.2",
|
|
60
60
|
"typescript": "^5.3.3",
|
|
61
61
|
"@empiricalrun/llm": "^0.9.26",
|
|
62
|
-
"@empiricalrun/
|
|
63
|
-
"@empiricalrun/
|
|
62
|
+
"@empiricalrun/reporter": "^0.21.3",
|
|
63
|
+
"@empiricalrun/r2-uploader": "^0.3.6"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"@types/detect-port": "^1.3.5",
|