@riddledc/riddle-proof 0.7.139 → 0.7.141
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/README.md +10 -2
- package/dist/{chunk-DB6J53V5.js → chunk-F46O7DP2.js} +174 -8
- package/dist/cli.cjs +203 -9
- package/dist/cli.js +30 -2
- package/dist/index.cjs +174 -8
- package/dist/index.js +1 -1
- package/dist/profile.cjs +174 -8
- package/dist/profile.d.cts +3 -1
- package/dist/profile.d.ts +3 -1
- package/dist/profile.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -8794,6 +8794,7 @@ var RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES = [
|
|
|
8794
8794
|
"wait",
|
|
8795
8795
|
"wait_for_selector",
|
|
8796
8796
|
"wait_for_text",
|
|
8797
|
+
"window_eval",
|
|
8797
8798
|
"window_call",
|
|
8798
8799
|
"window_call_until"
|
|
8799
8800
|
];
|
|
@@ -9213,6 +9214,21 @@ function profileSetupWindowCallReceipts(results) {
|
|
|
9213
9214
|
return receipt;
|
|
9214
9215
|
});
|
|
9215
9216
|
}
|
|
9217
|
+
function profileSetupWindowEvalReceipts(results) {
|
|
9218
|
+
return results.filter((result) => profileSetupResultAction(result) === "window_eval").map((result) => {
|
|
9219
|
+
const receipt = {
|
|
9220
|
+
ordinal: result.ordinal ?? null,
|
|
9221
|
+
ok: result.ok !== false,
|
|
9222
|
+
script_length: result.script_length ?? null,
|
|
9223
|
+
return_captured: result.return_captured ?? null,
|
|
9224
|
+
return_stored_to: result.return_stored_to ?? null,
|
|
9225
|
+
reason: result.reason ?? result.error ?? result.store_reason ?? null
|
|
9226
|
+
};
|
|
9227
|
+
if (result.returned !== void 0) receipt.returned = result.returned;
|
|
9228
|
+
if (result.expected_return !== void 0) receipt.expected_return = result.expected_return;
|
|
9229
|
+
return receipt;
|
|
9230
|
+
});
|
|
9231
|
+
}
|
|
9216
9232
|
function sampleProfileSetupSummaryItems(items, limit) {
|
|
9217
9233
|
if (items.length <= limit) return items;
|
|
9218
9234
|
const firstCount = Math.floor(limit / 2);
|
|
@@ -9227,12 +9243,18 @@ function profileScreenshotLabels(viewports) {
|
|
|
9227
9243
|
}
|
|
9228
9244
|
return labels;
|
|
9229
9245
|
}
|
|
9230
|
-
function profileSetupSummary(viewports, actionCount, expectedActionCountByViewport) {
|
|
9246
|
+
function profileSetupSummary(viewports, actionCount, expectedActionCountByViewport, finalScreenshotFullPage) {
|
|
9247
|
+
const normalizedFinalScreenshotFullPage = finalScreenshotFullPage === void 0 ? void 0 : finalScreenshotFullPage !== false;
|
|
9248
|
+
const finalScreenshotCount = viewports.filter((viewport) => typeof viewport.screenshot_label === "string" && viewport.screenshot_label.trim()).length;
|
|
9231
9249
|
return toJsonValue({
|
|
9232
9250
|
viewport_count: viewports.length,
|
|
9233
9251
|
action_count: actionCount ?? null,
|
|
9252
|
+
final_screenshot_count: finalScreenshotCount,
|
|
9253
|
+
final_screenshot_full_page: normalizedFinalScreenshotFullPage ?? null,
|
|
9254
|
+
final_screenshot_mode: normalizedFinalScreenshotFullPage === void 0 ? null : normalizedFinalScreenshotFullPage ? "full_page" : "viewport",
|
|
9234
9255
|
viewports: viewports.map((viewport) => {
|
|
9235
9256
|
const expectedActionCount = expectedActionCountByViewport?.get(viewport.name) ?? actionCount;
|
|
9257
|
+
const viewportFinalScreenshotFullPage = typeof viewport.screenshot_full_page === "boolean" ? viewport.screenshot_full_page : normalizedFinalScreenshotFullPage;
|
|
9236
9258
|
const results = viewport.setup_action_results || [];
|
|
9237
9259
|
const failed = results.filter((result) => result.ok === false && result.optional !== true);
|
|
9238
9260
|
const optionalFailed = results.filter((result) => result.ok === false && result.optional === true);
|
|
@@ -9245,6 +9267,10 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountByViewpo
|
|
|
9245
9267
|
const windowCallStoredTotal = windowCallReceipts.filter((result) => typeof result.return_stored_to === "string" && result.return_stored_to.trim()).length;
|
|
9246
9268
|
const windowCallCapturedTotal = windowCallReceipts.filter((result) => result.return_captured === true).length;
|
|
9247
9269
|
const sampledWindowCallReceipts = sampleProfileSetupSummaryItems(windowCallReceipts, 8);
|
|
9270
|
+
const windowEvalReceipts = profileSetupWindowEvalReceipts(results);
|
|
9271
|
+
const windowEvalStoredTotal = windowEvalReceipts.filter((result) => typeof result.return_stored_to === "string" && result.return_stored_to.trim()).length;
|
|
9272
|
+
const windowEvalCapturedTotal = windowEvalReceipts.filter((result) => result.return_captured === true).length;
|
|
9273
|
+
const sampledWindowEvalReceipts = sampleProfileSetupSummaryItems(windowEvalReceipts, 8);
|
|
9248
9274
|
const clickedItems = results.filter((result) => profileSetupResultAction(result) === "click" && result.ok !== false).map((result) => {
|
|
9249
9275
|
const clickCount = typeof result.click_count === "number" && Number.isFinite(result.click_count) && result.click_count > 1 ? result.click_count : void 0;
|
|
9250
9276
|
return {
|
|
@@ -9272,6 +9298,8 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountByViewpo
|
|
|
9272
9298
|
action_counts: profileSetupActionCounts(results),
|
|
9273
9299
|
frame_action_count: results.filter((result) => result.frame_selector).length,
|
|
9274
9300
|
frame_urls: profileSetupFrameUrls(viewport),
|
|
9301
|
+
final_screenshot: viewport.screenshot_label ?? null,
|
|
9302
|
+
final_screenshot_full_page: viewportFinalScreenshotFullPage ?? null,
|
|
9275
9303
|
setup_screenshots: profileSetupScreenshotLabels(results),
|
|
9276
9304
|
clicked_total: clickedItems.length,
|
|
9277
9305
|
clicked_truncated: clickedItems.length > clicked.length,
|
|
@@ -9286,6 +9314,11 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountByViewpo
|
|
|
9286
9314
|
window_call_captured_total: windowCallCapturedTotal,
|
|
9287
9315
|
window_call_truncated: windowCallReceipts.length > sampledWindowCallReceipts.length,
|
|
9288
9316
|
window_call: sampledWindowCallReceipts,
|
|
9317
|
+
window_eval_total: windowEvalReceipts.length,
|
|
9318
|
+
window_eval_stored_total: windowEvalStoredTotal,
|
|
9319
|
+
window_eval_captured_total: windowEvalCapturedTotal,
|
|
9320
|
+
window_eval_truncated: windowEvalReceipts.length > sampledWindowEvalReceipts.length,
|
|
9321
|
+
window_eval: sampledWindowEvalReceipts,
|
|
9289
9322
|
clicked,
|
|
9290
9323
|
text_samples,
|
|
9291
9324
|
failed: failed.map((result) => ({
|
|
@@ -9338,7 +9371,7 @@ function isSupportedCheckType(value) {
|
|
|
9338
9371
|
}
|
|
9339
9372
|
function normalizeSetupActionType(value, index) {
|
|
9340
9373
|
const normalizedInput = String(value || "").trim().replace(/-/g, "_");
|
|
9341
|
-
const normalized = normalizedInput === "clear_browser_storage" ? "clear_storage" : normalizedInput === "reset_console" || normalizedInput === "clear_browser_console" || normalizedInput === "reset_browser_console" ? "clear_console" : normalizedInput === "pointer_drag" || normalizedInput === "mouse_drag" || normalizedInput === "drag_to" ? "drag" : normalizedInput === "keyboard_press" || normalizedInput === "key_press" ? "press" : normalizedInput === "capture_screenshot" || normalizedInput === "save_screenshot" || normalizedInput === "setup_screenshot" ? "screenshot" : normalizedInput === "accept_dialog" || normalizedInput === "accept_dialogs" || normalizedInput === "confirm_dialog" || normalizedInput === "set_dialog_response" ? "dialog_response" : normalizedInput === "dismiss_dialog" || normalizedInput === "dismiss_dialogs" || normalizedInput === "cancel_dialog" ? "dialog_response" : normalizedInput === "window_call_until" || normalizedInput === "call_until" || normalizedInput === "window_call_repeat_until" || normalizedInput === "repeat_window_call_until" ? "window_call_until" : normalizedInput;
|
|
9374
|
+
const normalized = normalizedInput === "clear_browser_storage" ? "clear_storage" : normalizedInput === "reset_console" || normalizedInput === "clear_browser_console" || normalizedInput === "reset_browser_console" ? "clear_console" : normalizedInput === "pointer_drag" || normalizedInput === "mouse_drag" || normalizedInput === "drag_to" ? "drag" : normalizedInput === "keyboard_press" || normalizedInput === "key_press" ? "press" : normalizedInput === "capture_screenshot" || normalizedInput === "save_screenshot" || normalizedInput === "setup_screenshot" ? "screenshot" : normalizedInput === "accept_dialog" || normalizedInput === "accept_dialogs" || normalizedInput === "confirm_dialog" || normalizedInput === "set_dialog_response" ? "dialog_response" : normalizedInput === "dismiss_dialog" || normalizedInput === "dismiss_dialogs" || normalizedInput === "cancel_dialog" ? "dialog_response" : normalizedInput === "window_call_until" || normalizedInput === "call_until" || normalizedInput === "window_call_repeat_until" || normalizedInput === "repeat_window_call_until" ? "window_call_until" : normalizedInput === "window_evaluate" || normalizedInput === "browser_eval" || normalizedInput === "browser_evaluate" || normalizedInput === "evaluate_script" || normalizedInput === "profile_script" ? "window_eval" : normalizedInput;
|
|
9342
9375
|
if (RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES.includes(normalized)) {
|
|
9343
9376
|
return normalized;
|
|
9344
9377
|
}
|
|
@@ -9356,7 +9389,7 @@ function normalizeSetupActionArgs(input, index) {
|
|
|
9356
9389
|
const argsInput = valueFromOwn(input, "args", "arguments", "args_json", "argsJson");
|
|
9357
9390
|
if (argsInput === void 0) return void 0;
|
|
9358
9391
|
if (!Array.isArray(argsInput)) {
|
|
9359
|
-
throw new Error(`target.setup_actions[${index}] window_call args must be an array.`);
|
|
9392
|
+
throw new Error(`target.setup_actions[${index}] window_call/window_eval args must be an array.`);
|
|
9360
9393
|
}
|
|
9361
9394
|
return argsInput.map(toJsonValue);
|
|
9362
9395
|
}
|
|
@@ -9500,7 +9533,11 @@ function normalizeSetupAction(input, index) {
|
|
|
9500
9533
|
if ((type === "window_call" || type === "window_call_until" || type === "assert_window_value" || type === "assert_window_number") && !path6) {
|
|
9501
9534
|
throw new Error(`target.setup_actions[${index}] ${type} requires path.`);
|
|
9502
9535
|
}
|
|
9503
|
-
const
|
|
9536
|
+
const script = stringFromOwn(input, "script", "code", "source", "body");
|
|
9537
|
+
if (type === "window_eval" && !script) {
|
|
9538
|
+
throw new Error(`target.setup_actions[${index}] window_eval requires script.`);
|
|
9539
|
+
}
|
|
9540
|
+
const args = type === "window_call" || type === "window_call_until" || type === "window_eval" ? normalizeSetupActionArgs(input, index) : void 0;
|
|
9504
9541
|
const hasExpectedValue = hasOwn(input, "expected_value") || hasOwn(input, "expectedValue") || hasOwn(input, "expected") || hasOwn(input, "expect_value") || hasOwn(input, "expectValue") || hasOwn(input, "expect");
|
|
9505
9542
|
if (type === "assert_window_value" && !hasExpectedValue) {
|
|
9506
9543
|
throw new Error(`target.setup_actions[${index}] ${type} requires expected_value.`);
|
|
@@ -9571,6 +9608,7 @@ function normalizeSetupAction(input, index) {
|
|
|
9571
9608
|
value,
|
|
9572
9609
|
value_json: hasJsonValue ? toJsonValue(input.value_json ?? input.valueJson ?? input.json) : void 0,
|
|
9573
9610
|
label: stringFromOwn(input, "label", "name", "screenshot_label", "screenshotLabel"),
|
|
9611
|
+
script,
|
|
9574
9612
|
path: path6,
|
|
9575
9613
|
args,
|
|
9576
9614
|
expect_return: hasExpectedReturn ? toJsonValue(valueFromOwn(input, "expect_return", "expectReturn", "expected_return", "expectedReturn")) : void 0,
|
|
@@ -11516,7 +11554,7 @@ function assessSetupActionsFromEvidence(profile, evidence) {
|
|
|
11516
11554
|
ok: (viewport.setup_action_results || []).length >= (expectedActionCountByViewport.get(viewport.name) ?? actionCount) && (viewport.setup_action_results || []).every((result) => result.ok !== false || result.optional === true),
|
|
11517
11555
|
result_count: (viewport.setup_action_results || []).length
|
|
11518
11556
|
})),
|
|
11519
|
-
setup_summary: profileSetupSummary(viewports, actionCount, expectedActionCountByViewport),
|
|
11557
|
+
setup_summary: profileSetupSummary(viewports, actionCount, expectedActionCountByViewport, profile.target.screenshot_full_page),
|
|
11520
11558
|
failed
|
|
11521
11559
|
},
|
|
11522
11560
|
message: failed.length ? `Setup actions failed in ${failed.length} viewport action(s).` : void 0
|
|
@@ -12522,6 +12560,23 @@ function profileSetupWindowCallReceipts(results) {
|
|
|
12522
12560
|
return receipt;
|
|
12523
12561
|
});
|
|
12524
12562
|
}
|
|
12563
|
+
function profileSetupWindowEvalReceipts(results) {
|
|
12564
|
+
return (results || [])
|
|
12565
|
+
.filter((result) => result && profileSetupResultAction(result) === "window_eval")
|
|
12566
|
+
.map((result) => {
|
|
12567
|
+
const receipt = {
|
|
12568
|
+
ordinal: result.ordinal ?? null,
|
|
12569
|
+
ok: result.ok !== false,
|
|
12570
|
+
script_length: result.script_length ?? null,
|
|
12571
|
+
return_captured: result.return_captured ?? null,
|
|
12572
|
+
return_stored_to: result.return_stored_to ?? null,
|
|
12573
|
+
reason: result.reason || result.error || result.store_reason || null,
|
|
12574
|
+
};
|
|
12575
|
+
if (result.returned !== undefined) receipt.returned = result.returned;
|
|
12576
|
+
if (result.expected_return !== undefined) receipt.expected_return = result.expected_return;
|
|
12577
|
+
return receipt;
|
|
12578
|
+
});
|
|
12579
|
+
}
|
|
12525
12580
|
function sampleProfileSetupSummaryItems(items, limit) {
|
|
12526
12581
|
if ((items || []).length <= limit) return items || [];
|
|
12527
12582
|
const firstCount = Math.floor(limit / 2);
|
|
@@ -12536,14 +12591,28 @@ function profileScreenshotLabels(viewports) {
|
|
|
12536
12591
|
}
|
|
12537
12592
|
return labels;
|
|
12538
12593
|
}
|
|
12539
|
-
function profileSetupSummary(viewports, actionCount, expectedActionCountsByViewport) {
|
|
12594
|
+
function profileSetupSummary(viewports, actionCount, expectedActionCountsByViewport, finalScreenshotFullPage) {
|
|
12595
|
+
const normalizedFinalScreenshotFullPage = finalScreenshotFullPage === undefined
|
|
12596
|
+
? undefined
|
|
12597
|
+
: finalScreenshotFullPage !== false;
|
|
12598
|
+
const finalScreenshotCount = (viewports || []).filter((viewport) => viewport && typeof viewport.screenshot_label === "string" && viewport.screenshot_label.trim()).length;
|
|
12540
12599
|
return {
|
|
12541
12600
|
viewport_count: (viewports || []).length,
|
|
12542
12601
|
action_count: actionCount ?? null,
|
|
12602
|
+
final_screenshot_count: finalScreenshotCount,
|
|
12603
|
+
final_screenshot_full_page: normalizedFinalScreenshotFullPage ?? null,
|
|
12604
|
+
final_screenshot_mode: normalizedFinalScreenshotFullPage === undefined
|
|
12605
|
+
? null
|
|
12606
|
+
: normalizedFinalScreenshotFullPage
|
|
12607
|
+
? "full_page"
|
|
12608
|
+
: "viewport",
|
|
12543
12609
|
viewports: (viewports || []).map((viewport) => {
|
|
12544
12610
|
const expectedActionCount = expectedActionCountsByViewport && expectedActionCountsByViewport[viewport.name] !== undefined
|
|
12545
12611
|
? expectedActionCountsByViewport[viewport.name]
|
|
12546
12612
|
: actionCount;
|
|
12613
|
+
const viewportFinalScreenshotFullPage = typeof viewport.screenshot_full_page === "boolean"
|
|
12614
|
+
? viewport.screenshot_full_page
|
|
12615
|
+
: normalizedFinalScreenshotFullPage;
|
|
12547
12616
|
const results = viewport.setup_action_results || [];
|
|
12548
12617
|
const failed = results.filter((result) => result && result.ok === false && result.optional !== true);
|
|
12549
12618
|
const optionalFailed = results.filter((result) => result && result.ok === false && result.optional === true);
|
|
@@ -12560,6 +12629,10 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountsByViewp
|
|
|
12560
12629
|
const windowCallStoredTotal = windowCallReceipts.filter((result) => typeof result.return_stored_to === "string" && result.return_stored_to.trim()).length;
|
|
12561
12630
|
const windowCallCapturedTotal = windowCallReceipts.filter((result) => result.return_captured === true).length;
|
|
12562
12631
|
const sampledWindowCallReceipts = sampleProfileSetupSummaryItems(windowCallReceipts, 8);
|
|
12632
|
+
const windowEvalReceipts = profileSetupWindowEvalReceipts(results);
|
|
12633
|
+
const windowEvalStoredTotal = windowEvalReceipts.filter((result) => typeof result.return_stored_to === "string" && result.return_stored_to.trim()).length;
|
|
12634
|
+
const windowEvalCapturedTotal = windowEvalReceipts.filter((result) => result.return_captured === true).length;
|
|
12635
|
+
const sampledWindowEvalReceipts = sampleProfileSetupSummaryItems(windowEvalReceipts, 8);
|
|
12563
12636
|
const clickedItems = results
|
|
12564
12637
|
.filter((result) => result && profileSetupResultAction(result) === "click" && result.ok !== false)
|
|
12565
12638
|
.map((result) => {
|
|
@@ -12597,6 +12670,8 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountsByViewp
|
|
|
12597
12670
|
action_counts: profileSetupActionCounts(results),
|
|
12598
12671
|
frame_action_count: results.filter((result) => result && result.frame_selector).length,
|
|
12599
12672
|
frame_urls: profileSetupFrameUrls(viewport),
|
|
12673
|
+
final_screenshot: viewport.screenshot_label || null,
|
|
12674
|
+
final_screenshot_full_page: viewportFinalScreenshotFullPage ?? null,
|
|
12600
12675
|
setup_screenshots: profileSetupScreenshotLabels(results),
|
|
12601
12676
|
clicked_total: clickedItems.length,
|
|
12602
12677
|
clicked_truncated: clickedItems.length > clicked.length,
|
|
@@ -12611,6 +12686,11 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountsByViewp
|
|
|
12611
12686
|
window_call_captured_total: windowCallCapturedTotal,
|
|
12612
12687
|
window_call_truncated: windowCallReceipts.length > sampledWindowCallReceipts.length,
|
|
12613
12688
|
window_call: sampledWindowCallReceipts,
|
|
12689
|
+
window_eval_total: windowEvalReceipts.length,
|
|
12690
|
+
window_eval_stored_total: windowEvalStoredTotal,
|
|
12691
|
+
window_eval_captured_total: windowEvalCapturedTotal,
|
|
12692
|
+
window_eval_truncated: windowEvalReceipts.length > sampledWindowEvalReceipts.length,
|
|
12693
|
+
window_eval: sampledWindowEvalReceipts,
|
|
12614
12694
|
clicked,
|
|
12615
12695
|
text_samples: textSamples,
|
|
12616
12696
|
failed: failed.map((result) => ({
|
|
@@ -12781,7 +12861,7 @@ function assessProfile(profile, evidence) {
|
|
|
12781
12861
|
&& (viewport.setup_action_results || []).every((result) => !result || result.ok !== false || result.optional === true),
|
|
12782
12862
|
result_count: (viewport.setup_action_results || []).length,
|
|
12783
12863
|
})),
|
|
12784
|
-
setup_summary: profileSetupSummary(viewports, actionCount, expectedActionCountsByViewport),
|
|
12864
|
+
setup_summary: profileSetupSummary(viewports, actionCount, expectedActionCountsByViewport, profile.target && profile.target.screenshot_full_page),
|
|
12785
12865
|
failed,
|
|
12786
12866
|
},
|
|
12787
12867
|
message: failed.length ? "Setup actions failed in " + failed.length + " viewport action(s)." : undefined,
|
|
@@ -13591,6 +13671,49 @@ async function setupCallWindowFunction(context, path, args, storeReturnTo, captu
|
|
|
13591
13671
|
}
|
|
13592
13672
|
}, { path, args, storeReturnTo, captureReturn });
|
|
13593
13673
|
}
|
|
13674
|
+
async function setupEvaluateWindowScript(context, script, args, storeReturnTo, captureReturn) {
|
|
13675
|
+
return await context.evaluate(async ({ script, args, storeReturnTo, captureReturn }) => {
|
|
13676
|
+
const toJsonValue = (value) => {
|
|
13677
|
+
if (value === null || value === undefined) return null;
|
|
13678
|
+
if (typeof value === "string" || typeof value === "boolean") return value;
|
|
13679
|
+
if (typeof value === "number") return Number.isFinite(value) ? value : null;
|
|
13680
|
+
if (Array.isArray(value)) return value.map(toJsonValue);
|
|
13681
|
+
if (typeof value === "object") {
|
|
13682
|
+
return Object.fromEntries(Object.entries(value).map(([key, child]) => [key, toJsonValue(child)]));
|
|
13683
|
+
}
|
|
13684
|
+
return String(value);
|
|
13685
|
+
};
|
|
13686
|
+
const storeWindowReturn = (storePath, value) => {
|
|
13687
|
+
const pathParts = String(storePath || "").split(".").map((part) => part.trim()).filter(Boolean);
|
|
13688
|
+
if (pathParts[0] === "window") pathParts.shift();
|
|
13689
|
+
if (!pathParts.length) return { ok: false, reason: "missing_store_path" };
|
|
13690
|
+
let target = window;
|
|
13691
|
+
for (let index = 0; index < pathParts.length - 1; index += 1) {
|
|
13692
|
+
const part = pathParts[index];
|
|
13693
|
+
if (target[part] === null || typeof target[part] !== "object") target[part] = {};
|
|
13694
|
+
target = target[part];
|
|
13695
|
+
}
|
|
13696
|
+
target[pathParts[pathParts.length - 1]] = value;
|
|
13697
|
+
return { ok: true, path: pathParts.join(".") };
|
|
13698
|
+
};
|
|
13699
|
+
const body = String(script || "");
|
|
13700
|
+
if (!body.trim()) return { ok: false, reason: "missing_script" };
|
|
13701
|
+
try {
|
|
13702
|
+
const run = new Function("args", "\"use strict\"; return (async () => {\\n" + body + "\\n})();");
|
|
13703
|
+
const returned = await run(Array.isArray(args) ? args : []);
|
|
13704
|
+
const jsonReturned = toJsonValue(returned);
|
|
13705
|
+
const returnedForResult = captureReturn === false ? undefined : jsonReturned;
|
|
13706
|
+
if (storeReturnTo) {
|
|
13707
|
+
const stored = storeWindowReturn(storeReturnTo, jsonReturned);
|
|
13708
|
+
if (!stored.ok) return { ok: false, reason: "return_store_failed", store_reason: stored.reason, returned: returnedForResult };
|
|
13709
|
+
return { ok: true, returned: returnedForResult, return_stored_to: stored.path };
|
|
13710
|
+
}
|
|
13711
|
+
return { ok: true, returned: returnedForResult };
|
|
13712
|
+
} catch (error) {
|
|
13713
|
+
return { ok: false, reason: "script_threw", error: String(error && error.message ? error.message : error).slice(0, 1000) };
|
|
13714
|
+
}
|
|
13715
|
+
}, { script, args, storeReturnTo, captureReturn });
|
|
13716
|
+
}
|
|
13594
13717
|
function setupFrameSelector(action) {
|
|
13595
13718
|
return String(action?.frame_selector || action?.frameSelector || action?.iframe_selector || action?.iframeSelector || "").trim();
|
|
13596
13719
|
}
|
|
@@ -14104,6 +14227,44 @@ async function executeSetupAction(action, ordinal, viewport) {
|
|
|
14104
14227
|
}
|
|
14105
14228
|
return { ...base, ...setupScopeEvidence(scope), ok: true, storage, reload: action.reload === true };
|
|
14106
14229
|
}
|
|
14230
|
+
if (type === "window_eval") {
|
|
14231
|
+
const script = String(action.script || action.code || action.source || action.body || "");
|
|
14232
|
+
const args = Array.isArray(action.args) ? action.args : [];
|
|
14233
|
+
const storeReturnTo = String(action.store_return_to || action.storeReturnTo || action.save_return_to || action.saveReturnTo || action.assign_return_to || action.assignReturnTo || action.return_state_path || action.returnStatePath || "").trim();
|
|
14234
|
+
if (!script.trim()) return { ...base, reason: "missing_script" };
|
|
14235
|
+
const scope = await setupActionScope(action, timeout);
|
|
14236
|
+
if (!scope.ok) return setupScopeFailure(base, scope);
|
|
14237
|
+
const hasExpectation = setupHasOwn(action, "expect_return")
|
|
14238
|
+
|| setupHasOwn(action, "expectReturn")
|
|
14239
|
+
|| setupHasOwn(action, "expected_return")
|
|
14240
|
+
|| setupHasOwn(action, "expectedReturn");
|
|
14241
|
+
const expected = setupHasOwn(action, "expect_return")
|
|
14242
|
+
? action.expect_return
|
|
14243
|
+
: setupHasOwn(action, "expectReturn")
|
|
14244
|
+
? action.expectReturn
|
|
14245
|
+
: setupHasOwn(action, "expected_return")
|
|
14246
|
+
? action.expected_return
|
|
14247
|
+
: action.expectedReturn;
|
|
14248
|
+
const captureReturn = action.capture_return === false || action.captureReturn === false || action.include_return === false || action.includeReturn === false || action.omit_return === true || action.omitReturn === true
|
|
14249
|
+
? hasExpectation
|
|
14250
|
+
: true;
|
|
14251
|
+
const result = await setupEvaluateWindowScript(scope.context, script, args, storeReturnTo, captureReturn);
|
|
14252
|
+
const expectationMet = !hasExpectation || setupValuesEqual(result.returned, expected);
|
|
14253
|
+
return {
|
|
14254
|
+
...base,
|
|
14255
|
+
...setupScopeEvidence(scope),
|
|
14256
|
+
ok: Boolean(result.ok && expectationMet),
|
|
14257
|
+
script_length: script.length,
|
|
14258
|
+
arg_count: args.length,
|
|
14259
|
+
returned: captureReturn ? setupJsonValue(result.returned) : undefined,
|
|
14260
|
+
return_captured: captureReturn,
|
|
14261
|
+
expected_return: hasExpectation ? setupJsonValue(expected) : undefined,
|
|
14262
|
+
return_stored_to: result.return_stored_to || storeReturnTo || undefined,
|
|
14263
|
+
reason: result.ok ? (expectationMet ? undefined : "unexpected_return_value") : result.reason,
|
|
14264
|
+
store_reason: result.store_reason || undefined,
|
|
14265
|
+
error: result.error || undefined,
|
|
14266
|
+
};
|
|
14267
|
+
}
|
|
14107
14268
|
if (type === "window_call") {
|
|
14108
14269
|
const path = String(action.path || action.function_path || action.functionPath || "");
|
|
14109
14270
|
const args = Array.isArray(action.args) ? action.args : [];
|
|
@@ -15659,9 +15820,13 @@ async function captureViewport(viewport) {
|
|
|
15659
15820
|
}
|
|
15660
15821
|
}
|
|
15661
15822
|
const screenshotLabel = profileSlug + "-" + viewport.name;
|
|
15823
|
+
let screenshotFullPage = null;
|
|
15662
15824
|
try {
|
|
15663
15825
|
const screenshotOptions = {};
|
|
15664
|
-
if (profile.target && profile.target.screenshot_full_page !== undefined)
|
|
15826
|
+
if (profile.target && profile.target.screenshot_full_page !== undefined) {
|
|
15827
|
+
screenshotFullPage = profile.target.screenshot_full_page !== false;
|
|
15828
|
+
screenshotOptions.fullPage = screenshotFullPage;
|
|
15829
|
+
}
|
|
15665
15830
|
if (typeof saveScreenshot === "function") await saveScreenshot(screenshotLabel, screenshotOptions);
|
|
15666
15831
|
} catch (error) {
|
|
15667
15832
|
pageErrors.push({ message: "saveScreenshot failed: " + String(error && error.message ? error.message : error).slice(0, 500) });
|
|
@@ -15729,6 +15894,7 @@ async function captureViewport(viewport) {
|
|
|
15729
15894
|
route_inventory: routeInventory,
|
|
15730
15895
|
setup_action_results: setupActionResults,
|
|
15731
15896
|
screenshot_label: screenshotLabel,
|
|
15897
|
+
screenshot_full_page: screenshotFullPage,
|
|
15732
15898
|
navigation_error: navigationError,
|
|
15733
15899
|
wait_error: waitError,
|
|
15734
15900
|
};
|
package/dist/index.js
CHANGED
|
@@ -62,7 +62,7 @@ import {
|
|
|
62
62
|
resolveRiddleProofProfileTimeoutSec,
|
|
63
63
|
slugifyRiddleProofProfileName,
|
|
64
64
|
summarizeRiddleProofProfileResult
|
|
65
|
-
} from "./chunk-
|
|
65
|
+
} from "./chunk-F46O7DP2.js";
|
|
66
66
|
import {
|
|
67
67
|
DEFAULT_RIDDLE_API_BASE_URL,
|
|
68
68
|
DEFAULT_RIDDLE_API_KEY_FILE,
|