@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/profile.cjs
CHANGED
|
@@ -108,6 +108,7 @@ var RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES = [
|
|
|
108
108
|
"wait",
|
|
109
109
|
"wait_for_selector",
|
|
110
110
|
"wait_for_text",
|
|
111
|
+
"window_eval",
|
|
111
112
|
"window_call",
|
|
112
113
|
"window_call_until"
|
|
113
114
|
];
|
|
@@ -527,6 +528,21 @@ function profileSetupWindowCallReceipts(results) {
|
|
|
527
528
|
return receipt;
|
|
528
529
|
});
|
|
529
530
|
}
|
|
531
|
+
function profileSetupWindowEvalReceipts(results) {
|
|
532
|
+
return results.filter((result) => profileSetupResultAction(result) === "window_eval").map((result) => {
|
|
533
|
+
const receipt = {
|
|
534
|
+
ordinal: result.ordinal ?? null,
|
|
535
|
+
ok: result.ok !== false,
|
|
536
|
+
script_length: result.script_length ?? null,
|
|
537
|
+
return_captured: result.return_captured ?? null,
|
|
538
|
+
return_stored_to: result.return_stored_to ?? null,
|
|
539
|
+
reason: result.reason ?? result.error ?? result.store_reason ?? null
|
|
540
|
+
};
|
|
541
|
+
if (result.returned !== void 0) receipt.returned = result.returned;
|
|
542
|
+
if (result.expected_return !== void 0) receipt.expected_return = result.expected_return;
|
|
543
|
+
return receipt;
|
|
544
|
+
});
|
|
545
|
+
}
|
|
530
546
|
function sampleProfileSetupSummaryItems(items, limit) {
|
|
531
547
|
if (items.length <= limit) return items;
|
|
532
548
|
const firstCount = Math.floor(limit / 2);
|
|
@@ -541,12 +557,18 @@ function profileScreenshotLabels(viewports) {
|
|
|
541
557
|
}
|
|
542
558
|
return labels;
|
|
543
559
|
}
|
|
544
|
-
function profileSetupSummary(viewports, actionCount, expectedActionCountByViewport) {
|
|
560
|
+
function profileSetupSummary(viewports, actionCount, expectedActionCountByViewport, finalScreenshotFullPage) {
|
|
561
|
+
const normalizedFinalScreenshotFullPage = finalScreenshotFullPage === void 0 ? void 0 : finalScreenshotFullPage !== false;
|
|
562
|
+
const finalScreenshotCount = viewports.filter((viewport) => typeof viewport.screenshot_label === "string" && viewport.screenshot_label.trim()).length;
|
|
545
563
|
return toJsonValue({
|
|
546
564
|
viewport_count: viewports.length,
|
|
547
565
|
action_count: actionCount ?? null,
|
|
566
|
+
final_screenshot_count: finalScreenshotCount,
|
|
567
|
+
final_screenshot_full_page: normalizedFinalScreenshotFullPage ?? null,
|
|
568
|
+
final_screenshot_mode: normalizedFinalScreenshotFullPage === void 0 ? null : normalizedFinalScreenshotFullPage ? "full_page" : "viewport",
|
|
548
569
|
viewports: viewports.map((viewport) => {
|
|
549
570
|
const expectedActionCount = expectedActionCountByViewport?.get(viewport.name) ?? actionCount;
|
|
571
|
+
const viewportFinalScreenshotFullPage = typeof viewport.screenshot_full_page === "boolean" ? viewport.screenshot_full_page : normalizedFinalScreenshotFullPage;
|
|
550
572
|
const results = viewport.setup_action_results || [];
|
|
551
573
|
const failed = results.filter((result) => result.ok === false && result.optional !== true);
|
|
552
574
|
const optionalFailed = results.filter((result) => result.ok === false && result.optional === true);
|
|
@@ -559,6 +581,10 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountByViewpo
|
|
|
559
581
|
const windowCallStoredTotal = windowCallReceipts.filter((result) => typeof result.return_stored_to === "string" && result.return_stored_to.trim()).length;
|
|
560
582
|
const windowCallCapturedTotal = windowCallReceipts.filter((result) => result.return_captured === true).length;
|
|
561
583
|
const sampledWindowCallReceipts = sampleProfileSetupSummaryItems(windowCallReceipts, 8);
|
|
584
|
+
const windowEvalReceipts = profileSetupWindowEvalReceipts(results);
|
|
585
|
+
const windowEvalStoredTotal = windowEvalReceipts.filter((result) => typeof result.return_stored_to === "string" && result.return_stored_to.trim()).length;
|
|
586
|
+
const windowEvalCapturedTotal = windowEvalReceipts.filter((result) => result.return_captured === true).length;
|
|
587
|
+
const sampledWindowEvalReceipts = sampleProfileSetupSummaryItems(windowEvalReceipts, 8);
|
|
562
588
|
const clickedItems = results.filter((result) => profileSetupResultAction(result) === "click" && result.ok !== false).map((result) => {
|
|
563
589
|
const clickCount = typeof result.click_count === "number" && Number.isFinite(result.click_count) && result.click_count > 1 ? result.click_count : void 0;
|
|
564
590
|
return {
|
|
@@ -586,6 +612,8 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountByViewpo
|
|
|
586
612
|
action_counts: profileSetupActionCounts(results),
|
|
587
613
|
frame_action_count: results.filter((result) => result.frame_selector).length,
|
|
588
614
|
frame_urls: profileSetupFrameUrls(viewport),
|
|
615
|
+
final_screenshot: viewport.screenshot_label ?? null,
|
|
616
|
+
final_screenshot_full_page: viewportFinalScreenshotFullPage ?? null,
|
|
589
617
|
setup_screenshots: profileSetupScreenshotLabels(results),
|
|
590
618
|
clicked_total: clickedItems.length,
|
|
591
619
|
clicked_truncated: clickedItems.length > clicked.length,
|
|
@@ -600,6 +628,11 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountByViewpo
|
|
|
600
628
|
window_call_captured_total: windowCallCapturedTotal,
|
|
601
629
|
window_call_truncated: windowCallReceipts.length > sampledWindowCallReceipts.length,
|
|
602
630
|
window_call: sampledWindowCallReceipts,
|
|
631
|
+
window_eval_total: windowEvalReceipts.length,
|
|
632
|
+
window_eval_stored_total: windowEvalStoredTotal,
|
|
633
|
+
window_eval_captured_total: windowEvalCapturedTotal,
|
|
634
|
+
window_eval_truncated: windowEvalReceipts.length > sampledWindowEvalReceipts.length,
|
|
635
|
+
window_eval: sampledWindowEvalReceipts,
|
|
603
636
|
clicked,
|
|
604
637
|
text_samples,
|
|
605
638
|
failed: failed.map((result) => ({
|
|
@@ -652,7 +685,7 @@ function isSupportedCheckType(value) {
|
|
|
652
685
|
}
|
|
653
686
|
function normalizeSetupActionType(value, index) {
|
|
654
687
|
const normalizedInput = String(value || "").trim().replace(/-/g, "_");
|
|
655
|
-
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;
|
|
688
|
+
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;
|
|
656
689
|
if (RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES.includes(normalized)) {
|
|
657
690
|
return normalized;
|
|
658
691
|
}
|
|
@@ -670,7 +703,7 @@ function normalizeSetupActionArgs(input, index) {
|
|
|
670
703
|
const argsInput = valueFromOwn(input, "args", "arguments", "args_json", "argsJson");
|
|
671
704
|
if (argsInput === void 0) return void 0;
|
|
672
705
|
if (!Array.isArray(argsInput)) {
|
|
673
|
-
throw new Error(`target.setup_actions[${index}] window_call args must be an array.`);
|
|
706
|
+
throw new Error(`target.setup_actions[${index}] window_call/window_eval args must be an array.`);
|
|
674
707
|
}
|
|
675
708
|
return argsInput.map(toJsonValue);
|
|
676
709
|
}
|
|
@@ -814,7 +847,11 @@ function normalizeSetupAction(input, index) {
|
|
|
814
847
|
if ((type === "window_call" || type === "window_call_until" || type === "assert_window_value" || type === "assert_window_number") && !path) {
|
|
815
848
|
throw new Error(`target.setup_actions[${index}] ${type} requires path.`);
|
|
816
849
|
}
|
|
817
|
-
const
|
|
850
|
+
const script = stringFromOwn(input, "script", "code", "source", "body");
|
|
851
|
+
if (type === "window_eval" && !script) {
|
|
852
|
+
throw new Error(`target.setup_actions[${index}] window_eval requires script.`);
|
|
853
|
+
}
|
|
854
|
+
const args = type === "window_call" || type === "window_call_until" || type === "window_eval" ? normalizeSetupActionArgs(input, index) : void 0;
|
|
818
855
|
const hasExpectedValue = hasOwn(input, "expected_value") || hasOwn(input, "expectedValue") || hasOwn(input, "expected") || hasOwn(input, "expect_value") || hasOwn(input, "expectValue") || hasOwn(input, "expect");
|
|
819
856
|
if (type === "assert_window_value" && !hasExpectedValue) {
|
|
820
857
|
throw new Error(`target.setup_actions[${index}] ${type} requires expected_value.`);
|
|
@@ -885,6 +922,7 @@ function normalizeSetupAction(input, index) {
|
|
|
885
922
|
value,
|
|
886
923
|
value_json: hasJsonValue ? toJsonValue(input.value_json ?? input.valueJson ?? input.json) : void 0,
|
|
887
924
|
label: stringFromOwn(input, "label", "name", "screenshot_label", "screenshotLabel"),
|
|
925
|
+
script,
|
|
888
926
|
path,
|
|
889
927
|
args,
|
|
890
928
|
expect_return: hasExpectedReturn ? toJsonValue(valueFromOwn(input, "expect_return", "expectReturn", "expected_return", "expectedReturn")) : void 0,
|
|
@@ -2830,7 +2868,7 @@ function assessSetupActionsFromEvidence(profile, evidence) {
|
|
|
2830
2868
|
ok: (viewport.setup_action_results || []).length >= (expectedActionCountByViewport.get(viewport.name) ?? actionCount) && (viewport.setup_action_results || []).every((result) => result.ok !== false || result.optional === true),
|
|
2831
2869
|
result_count: (viewport.setup_action_results || []).length
|
|
2832
2870
|
})),
|
|
2833
|
-
setup_summary: profileSetupSummary(viewports, actionCount, expectedActionCountByViewport),
|
|
2871
|
+
setup_summary: profileSetupSummary(viewports, actionCount, expectedActionCountByViewport, profile.target.screenshot_full_page),
|
|
2834
2872
|
failed
|
|
2835
2873
|
},
|
|
2836
2874
|
message: failed.length ? `Setup actions failed in ${failed.length} viewport action(s).` : void 0
|
|
@@ -3836,6 +3874,23 @@ function profileSetupWindowCallReceipts(results) {
|
|
|
3836
3874
|
return receipt;
|
|
3837
3875
|
});
|
|
3838
3876
|
}
|
|
3877
|
+
function profileSetupWindowEvalReceipts(results) {
|
|
3878
|
+
return (results || [])
|
|
3879
|
+
.filter((result) => result && profileSetupResultAction(result) === "window_eval")
|
|
3880
|
+
.map((result) => {
|
|
3881
|
+
const receipt = {
|
|
3882
|
+
ordinal: result.ordinal ?? null,
|
|
3883
|
+
ok: result.ok !== false,
|
|
3884
|
+
script_length: result.script_length ?? null,
|
|
3885
|
+
return_captured: result.return_captured ?? null,
|
|
3886
|
+
return_stored_to: result.return_stored_to ?? null,
|
|
3887
|
+
reason: result.reason || result.error || result.store_reason || null,
|
|
3888
|
+
};
|
|
3889
|
+
if (result.returned !== undefined) receipt.returned = result.returned;
|
|
3890
|
+
if (result.expected_return !== undefined) receipt.expected_return = result.expected_return;
|
|
3891
|
+
return receipt;
|
|
3892
|
+
});
|
|
3893
|
+
}
|
|
3839
3894
|
function sampleProfileSetupSummaryItems(items, limit) {
|
|
3840
3895
|
if ((items || []).length <= limit) return items || [];
|
|
3841
3896
|
const firstCount = Math.floor(limit / 2);
|
|
@@ -3850,14 +3905,28 @@ function profileScreenshotLabels(viewports) {
|
|
|
3850
3905
|
}
|
|
3851
3906
|
return labels;
|
|
3852
3907
|
}
|
|
3853
|
-
function profileSetupSummary(viewports, actionCount, expectedActionCountsByViewport) {
|
|
3908
|
+
function profileSetupSummary(viewports, actionCount, expectedActionCountsByViewport, finalScreenshotFullPage) {
|
|
3909
|
+
const normalizedFinalScreenshotFullPage = finalScreenshotFullPage === undefined
|
|
3910
|
+
? undefined
|
|
3911
|
+
: finalScreenshotFullPage !== false;
|
|
3912
|
+
const finalScreenshotCount = (viewports || []).filter((viewport) => viewport && typeof viewport.screenshot_label === "string" && viewport.screenshot_label.trim()).length;
|
|
3854
3913
|
return {
|
|
3855
3914
|
viewport_count: (viewports || []).length,
|
|
3856
3915
|
action_count: actionCount ?? null,
|
|
3916
|
+
final_screenshot_count: finalScreenshotCount,
|
|
3917
|
+
final_screenshot_full_page: normalizedFinalScreenshotFullPage ?? null,
|
|
3918
|
+
final_screenshot_mode: normalizedFinalScreenshotFullPage === undefined
|
|
3919
|
+
? null
|
|
3920
|
+
: normalizedFinalScreenshotFullPage
|
|
3921
|
+
? "full_page"
|
|
3922
|
+
: "viewport",
|
|
3857
3923
|
viewports: (viewports || []).map((viewport) => {
|
|
3858
3924
|
const expectedActionCount = expectedActionCountsByViewport && expectedActionCountsByViewport[viewport.name] !== undefined
|
|
3859
3925
|
? expectedActionCountsByViewport[viewport.name]
|
|
3860
3926
|
: actionCount;
|
|
3927
|
+
const viewportFinalScreenshotFullPage = typeof viewport.screenshot_full_page === "boolean"
|
|
3928
|
+
? viewport.screenshot_full_page
|
|
3929
|
+
: normalizedFinalScreenshotFullPage;
|
|
3861
3930
|
const results = viewport.setup_action_results || [];
|
|
3862
3931
|
const failed = results.filter((result) => result && result.ok === false && result.optional !== true);
|
|
3863
3932
|
const optionalFailed = results.filter((result) => result && result.ok === false && result.optional === true);
|
|
@@ -3874,6 +3943,10 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountsByViewp
|
|
|
3874
3943
|
const windowCallStoredTotal = windowCallReceipts.filter((result) => typeof result.return_stored_to === "string" && result.return_stored_to.trim()).length;
|
|
3875
3944
|
const windowCallCapturedTotal = windowCallReceipts.filter((result) => result.return_captured === true).length;
|
|
3876
3945
|
const sampledWindowCallReceipts = sampleProfileSetupSummaryItems(windowCallReceipts, 8);
|
|
3946
|
+
const windowEvalReceipts = profileSetupWindowEvalReceipts(results);
|
|
3947
|
+
const windowEvalStoredTotal = windowEvalReceipts.filter((result) => typeof result.return_stored_to === "string" && result.return_stored_to.trim()).length;
|
|
3948
|
+
const windowEvalCapturedTotal = windowEvalReceipts.filter((result) => result.return_captured === true).length;
|
|
3949
|
+
const sampledWindowEvalReceipts = sampleProfileSetupSummaryItems(windowEvalReceipts, 8);
|
|
3877
3950
|
const clickedItems = results
|
|
3878
3951
|
.filter((result) => result && profileSetupResultAction(result) === "click" && result.ok !== false)
|
|
3879
3952
|
.map((result) => {
|
|
@@ -3911,6 +3984,8 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountsByViewp
|
|
|
3911
3984
|
action_counts: profileSetupActionCounts(results),
|
|
3912
3985
|
frame_action_count: results.filter((result) => result && result.frame_selector).length,
|
|
3913
3986
|
frame_urls: profileSetupFrameUrls(viewport),
|
|
3987
|
+
final_screenshot: viewport.screenshot_label || null,
|
|
3988
|
+
final_screenshot_full_page: viewportFinalScreenshotFullPage ?? null,
|
|
3914
3989
|
setup_screenshots: profileSetupScreenshotLabels(results),
|
|
3915
3990
|
clicked_total: clickedItems.length,
|
|
3916
3991
|
clicked_truncated: clickedItems.length > clicked.length,
|
|
@@ -3925,6 +4000,11 @@ function profileSetupSummary(viewports, actionCount, expectedActionCountsByViewp
|
|
|
3925
4000
|
window_call_captured_total: windowCallCapturedTotal,
|
|
3926
4001
|
window_call_truncated: windowCallReceipts.length > sampledWindowCallReceipts.length,
|
|
3927
4002
|
window_call: sampledWindowCallReceipts,
|
|
4003
|
+
window_eval_total: windowEvalReceipts.length,
|
|
4004
|
+
window_eval_stored_total: windowEvalStoredTotal,
|
|
4005
|
+
window_eval_captured_total: windowEvalCapturedTotal,
|
|
4006
|
+
window_eval_truncated: windowEvalReceipts.length > sampledWindowEvalReceipts.length,
|
|
4007
|
+
window_eval: sampledWindowEvalReceipts,
|
|
3928
4008
|
clicked,
|
|
3929
4009
|
text_samples: textSamples,
|
|
3930
4010
|
failed: failed.map((result) => ({
|
|
@@ -4095,7 +4175,7 @@ function assessProfile(profile, evidence) {
|
|
|
4095
4175
|
&& (viewport.setup_action_results || []).every((result) => !result || result.ok !== false || result.optional === true),
|
|
4096
4176
|
result_count: (viewport.setup_action_results || []).length,
|
|
4097
4177
|
})),
|
|
4098
|
-
setup_summary: profileSetupSummary(viewports, actionCount, expectedActionCountsByViewport),
|
|
4178
|
+
setup_summary: profileSetupSummary(viewports, actionCount, expectedActionCountsByViewport, profile.target && profile.target.screenshot_full_page),
|
|
4099
4179
|
failed,
|
|
4100
4180
|
},
|
|
4101
4181
|
message: failed.length ? "Setup actions failed in " + failed.length + " viewport action(s)." : undefined,
|
|
@@ -4905,6 +4985,49 @@ async function setupCallWindowFunction(context, path, args, storeReturnTo, captu
|
|
|
4905
4985
|
}
|
|
4906
4986
|
}, { path, args, storeReturnTo, captureReturn });
|
|
4907
4987
|
}
|
|
4988
|
+
async function setupEvaluateWindowScript(context, script, args, storeReturnTo, captureReturn) {
|
|
4989
|
+
return await context.evaluate(async ({ script, args, storeReturnTo, captureReturn }) => {
|
|
4990
|
+
const toJsonValue = (value) => {
|
|
4991
|
+
if (value === null || value === undefined) return null;
|
|
4992
|
+
if (typeof value === "string" || typeof value === "boolean") return value;
|
|
4993
|
+
if (typeof value === "number") return Number.isFinite(value) ? value : null;
|
|
4994
|
+
if (Array.isArray(value)) return value.map(toJsonValue);
|
|
4995
|
+
if (typeof value === "object") {
|
|
4996
|
+
return Object.fromEntries(Object.entries(value).map(([key, child]) => [key, toJsonValue(child)]));
|
|
4997
|
+
}
|
|
4998
|
+
return String(value);
|
|
4999
|
+
};
|
|
5000
|
+
const storeWindowReturn = (storePath, value) => {
|
|
5001
|
+
const pathParts = String(storePath || "").split(".").map((part) => part.trim()).filter(Boolean);
|
|
5002
|
+
if (pathParts[0] === "window") pathParts.shift();
|
|
5003
|
+
if (!pathParts.length) return { ok: false, reason: "missing_store_path" };
|
|
5004
|
+
let target = window;
|
|
5005
|
+
for (let index = 0; index < pathParts.length - 1; index += 1) {
|
|
5006
|
+
const part = pathParts[index];
|
|
5007
|
+
if (target[part] === null || typeof target[part] !== "object") target[part] = {};
|
|
5008
|
+
target = target[part];
|
|
5009
|
+
}
|
|
5010
|
+
target[pathParts[pathParts.length - 1]] = value;
|
|
5011
|
+
return { ok: true, path: pathParts.join(".") };
|
|
5012
|
+
};
|
|
5013
|
+
const body = String(script || "");
|
|
5014
|
+
if (!body.trim()) return { ok: false, reason: "missing_script" };
|
|
5015
|
+
try {
|
|
5016
|
+
const run = new Function("args", "\"use strict\"; return (async () => {\\n" + body + "\\n})();");
|
|
5017
|
+
const returned = await run(Array.isArray(args) ? args : []);
|
|
5018
|
+
const jsonReturned = toJsonValue(returned);
|
|
5019
|
+
const returnedForResult = captureReturn === false ? undefined : jsonReturned;
|
|
5020
|
+
if (storeReturnTo) {
|
|
5021
|
+
const stored = storeWindowReturn(storeReturnTo, jsonReturned);
|
|
5022
|
+
if (!stored.ok) return { ok: false, reason: "return_store_failed", store_reason: stored.reason, returned: returnedForResult };
|
|
5023
|
+
return { ok: true, returned: returnedForResult, return_stored_to: stored.path };
|
|
5024
|
+
}
|
|
5025
|
+
return { ok: true, returned: returnedForResult };
|
|
5026
|
+
} catch (error) {
|
|
5027
|
+
return { ok: false, reason: "script_threw", error: String(error && error.message ? error.message : error).slice(0, 1000) };
|
|
5028
|
+
}
|
|
5029
|
+
}, { script, args, storeReturnTo, captureReturn });
|
|
5030
|
+
}
|
|
4908
5031
|
function setupFrameSelector(action) {
|
|
4909
5032
|
return String(action?.frame_selector || action?.frameSelector || action?.iframe_selector || action?.iframeSelector || "").trim();
|
|
4910
5033
|
}
|
|
@@ -5418,6 +5541,44 @@ async function executeSetupAction(action, ordinal, viewport) {
|
|
|
5418
5541
|
}
|
|
5419
5542
|
return { ...base, ...setupScopeEvidence(scope), ok: true, storage, reload: action.reload === true };
|
|
5420
5543
|
}
|
|
5544
|
+
if (type === "window_eval") {
|
|
5545
|
+
const script = String(action.script || action.code || action.source || action.body || "");
|
|
5546
|
+
const args = Array.isArray(action.args) ? action.args : [];
|
|
5547
|
+
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();
|
|
5548
|
+
if (!script.trim()) return { ...base, reason: "missing_script" };
|
|
5549
|
+
const scope = await setupActionScope(action, timeout);
|
|
5550
|
+
if (!scope.ok) return setupScopeFailure(base, scope);
|
|
5551
|
+
const hasExpectation = setupHasOwn(action, "expect_return")
|
|
5552
|
+
|| setupHasOwn(action, "expectReturn")
|
|
5553
|
+
|| setupHasOwn(action, "expected_return")
|
|
5554
|
+
|| setupHasOwn(action, "expectedReturn");
|
|
5555
|
+
const expected = setupHasOwn(action, "expect_return")
|
|
5556
|
+
? action.expect_return
|
|
5557
|
+
: setupHasOwn(action, "expectReturn")
|
|
5558
|
+
? action.expectReturn
|
|
5559
|
+
: setupHasOwn(action, "expected_return")
|
|
5560
|
+
? action.expected_return
|
|
5561
|
+
: action.expectedReturn;
|
|
5562
|
+
const captureReturn = action.capture_return === false || action.captureReturn === false || action.include_return === false || action.includeReturn === false || action.omit_return === true || action.omitReturn === true
|
|
5563
|
+
? hasExpectation
|
|
5564
|
+
: true;
|
|
5565
|
+
const result = await setupEvaluateWindowScript(scope.context, script, args, storeReturnTo, captureReturn);
|
|
5566
|
+
const expectationMet = !hasExpectation || setupValuesEqual(result.returned, expected);
|
|
5567
|
+
return {
|
|
5568
|
+
...base,
|
|
5569
|
+
...setupScopeEvidence(scope),
|
|
5570
|
+
ok: Boolean(result.ok && expectationMet),
|
|
5571
|
+
script_length: script.length,
|
|
5572
|
+
arg_count: args.length,
|
|
5573
|
+
returned: captureReturn ? setupJsonValue(result.returned) : undefined,
|
|
5574
|
+
return_captured: captureReturn,
|
|
5575
|
+
expected_return: hasExpectation ? setupJsonValue(expected) : undefined,
|
|
5576
|
+
return_stored_to: result.return_stored_to || storeReturnTo || undefined,
|
|
5577
|
+
reason: result.ok ? (expectationMet ? undefined : "unexpected_return_value") : result.reason,
|
|
5578
|
+
store_reason: result.store_reason || undefined,
|
|
5579
|
+
error: result.error || undefined,
|
|
5580
|
+
};
|
|
5581
|
+
}
|
|
5421
5582
|
if (type === "window_call") {
|
|
5422
5583
|
const path = String(action.path || action.function_path || action.functionPath || "");
|
|
5423
5584
|
const args = Array.isArray(action.args) ? action.args : [];
|
|
@@ -6973,9 +7134,13 @@ async function captureViewport(viewport) {
|
|
|
6973
7134
|
}
|
|
6974
7135
|
}
|
|
6975
7136
|
const screenshotLabel = profileSlug + "-" + viewport.name;
|
|
7137
|
+
let screenshotFullPage = null;
|
|
6976
7138
|
try {
|
|
6977
7139
|
const screenshotOptions = {};
|
|
6978
|
-
if (profile.target && profile.target.screenshot_full_page !== undefined)
|
|
7140
|
+
if (profile.target && profile.target.screenshot_full_page !== undefined) {
|
|
7141
|
+
screenshotFullPage = profile.target.screenshot_full_page !== false;
|
|
7142
|
+
screenshotOptions.fullPage = screenshotFullPage;
|
|
7143
|
+
}
|
|
6979
7144
|
if (typeof saveScreenshot === "function") await saveScreenshot(screenshotLabel, screenshotOptions);
|
|
6980
7145
|
} catch (error) {
|
|
6981
7146
|
pageErrors.push({ message: "saveScreenshot failed: " + String(error && error.message ? error.message : error).slice(0, 500) });
|
|
@@ -7043,6 +7208,7 @@ async function captureViewport(viewport) {
|
|
|
7043
7208
|
route_inventory: routeInventory,
|
|
7044
7209
|
setup_action_results: setupActionResults,
|
|
7045
7210
|
screenshot_label: screenshotLabel,
|
|
7211
|
+
screenshot_full_page: screenshotFullPage,
|
|
7046
7212
|
navigation_error: navigationError,
|
|
7047
7213
|
wait_error: waitError,
|
|
7048
7214
|
};
|
package/dist/profile.d.cts
CHANGED
|
@@ -5,7 +5,7 @@ declare const RIDDLE_PROOF_PROFILE_EVIDENCE_VERSION: "riddle-proof.profile-evide
|
|
|
5
5
|
declare const RIDDLE_PROOF_PROFILE_RESULT_VERSION: "riddle-proof.profile-result.v1";
|
|
6
6
|
declare const RIDDLE_PROOF_PROFILE_STATUSES: readonly ["passed", "product_regression", "proof_insufficient", "environment_blocked", "configuration_error", "needs_human_review"];
|
|
7
7
|
declare const RIDDLE_PROOF_PROFILE_CHECK_TYPES: readonly ["route_loaded", "url_search_param_equals", "url_search_param_absent", "selector_visible", "selector_absent", "selector_count_at_least", "selector_count_equals", "selector_count_equal", "selector_count_eq", "dialog_count_equals", "dialog_accept_count_equals", "dialog_dismiss_count_equals", "selector_text_visible", "selector_text_absent", "selector_text_order", "frame_text_visible", "frame_url_equals", "frame_url_matches", "frame_no_horizontal_overflow", "text_visible", "text_absent", "http_status", "link_status", "artifact_link_status", "route_inventory", "no_horizontal_overflow", "no_mobile_horizontal_overflow", "no_fatal_console_errors", "no_console_warnings"];
|
|
8
|
-
declare const RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES: readonly ["click", "drag", "press", "fill", "set_input_value", "assert_text_visible", "assert_text_absent", "assert_selector_count", "assert_window_value", "assert_window_number", "local_storage", "session_storage", "clear_storage", "clear_console", "dialog_response", "screenshot", "wait", "wait_for_selector", "wait_for_text", "window_call", "window_call_until"];
|
|
8
|
+
declare const RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES: readonly ["click", "drag", "press", "fill", "set_input_value", "assert_text_visible", "assert_text_absent", "assert_selector_count", "assert_window_value", "assert_window_number", "local_storage", "session_storage", "clear_storage", "clear_console", "dialog_response", "screenshot", "wait", "wait_for_selector", "wait_for_text", "window_eval", "window_call", "window_call_until"];
|
|
9
9
|
type RiddleProofProfileStatus = typeof RIDDLE_PROOF_PROFILE_STATUSES[number];
|
|
10
10
|
type RiddleProofProfileCheckType = typeof RIDDLE_PROOF_PROFILE_CHECK_TYPES[number];
|
|
11
11
|
type RiddleProofProfileSetupActionType = typeof RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES[number];
|
|
@@ -127,6 +127,7 @@ interface RiddleProofProfileSetupAction {
|
|
|
127
127
|
value?: string;
|
|
128
128
|
value_json?: JsonValue;
|
|
129
129
|
label?: string;
|
|
130
|
+
script?: string;
|
|
130
131
|
path?: string;
|
|
131
132
|
args?: JsonValue[];
|
|
132
133
|
expect_return?: JsonValue;
|
|
@@ -323,6 +324,7 @@ interface RiddleProofProfileViewportEvidence {
|
|
|
323
324
|
route_inventory?: Record<string, JsonValue>;
|
|
324
325
|
setup_action_results?: Array<Record<string, JsonValue>>;
|
|
325
326
|
screenshot_label?: string;
|
|
327
|
+
screenshot_full_page?: boolean | null;
|
|
326
328
|
navigation_error?: string;
|
|
327
329
|
wait_error?: string;
|
|
328
330
|
}
|
package/dist/profile.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ declare const RIDDLE_PROOF_PROFILE_EVIDENCE_VERSION: "riddle-proof.profile-evide
|
|
|
5
5
|
declare const RIDDLE_PROOF_PROFILE_RESULT_VERSION: "riddle-proof.profile-result.v1";
|
|
6
6
|
declare const RIDDLE_PROOF_PROFILE_STATUSES: readonly ["passed", "product_regression", "proof_insufficient", "environment_blocked", "configuration_error", "needs_human_review"];
|
|
7
7
|
declare const RIDDLE_PROOF_PROFILE_CHECK_TYPES: readonly ["route_loaded", "url_search_param_equals", "url_search_param_absent", "selector_visible", "selector_absent", "selector_count_at_least", "selector_count_equals", "selector_count_equal", "selector_count_eq", "dialog_count_equals", "dialog_accept_count_equals", "dialog_dismiss_count_equals", "selector_text_visible", "selector_text_absent", "selector_text_order", "frame_text_visible", "frame_url_equals", "frame_url_matches", "frame_no_horizontal_overflow", "text_visible", "text_absent", "http_status", "link_status", "artifact_link_status", "route_inventory", "no_horizontal_overflow", "no_mobile_horizontal_overflow", "no_fatal_console_errors", "no_console_warnings"];
|
|
8
|
-
declare const RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES: readonly ["click", "drag", "press", "fill", "set_input_value", "assert_text_visible", "assert_text_absent", "assert_selector_count", "assert_window_value", "assert_window_number", "local_storage", "session_storage", "clear_storage", "clear_console", "dialog_response", "screenshot", "wait", "wait_for_selector", "wait_for_text", "window_call", "window_call_until"];
|
|
8
|
+
declare const RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES: readonly ["click", "drag", "press", "fill", "set_input_value", "assert_text_visible", "assert_text_absent", "assert_selector_count", "assert_window_value", "assert_window_number", "local_storage", "session_storage", "clear_storage", "clear_console", "dialog_response", "screenshot", "wait", "wait_for_selector", "wait_for_text", "window_eval", "window_call", "window_call_until"];
|
|
9
9
|
type RiddleProofProfileStatus = typeof RIDDLE_PROOF_PROFILE_STATUSES[number];
|
|
10
10
|
type RiddleProofProfileCheckType = typeof RIDDLE_PROOF_PROFILE_CHECK_TYPES[number];
|
|
11
11
|
type RiddleProofProfileSetupActionType = typeof RIDDLE_PROOF_PROFILE_SETUP_ACTION_TYPES[number];
|
|
@@ -127,6 +127,7 @@ interface RiddleProofProfileSetupAction {
|
|
|
127
127
|
value?: string;
|
|
128
128
|
value_json?: JsonValue;
|
|
129
129
|
label?: string;
|
|
130
|
+
script?: string;
|
|
130
131
|
path?: string;
|
|
131
132
|
args?: JsonValue[];
|
|
132
133
|
expect_return?: JsonValue;
|
|
@@ -323,6 +324,7 @@ interface RiddleProofProfileViewportEvidence {
|
|
|
323
324
|
route_inventory?: Record<string, JsonValue>;
|
|
324
325
|
setup_action_results?: Array<Record<string, JsonValue>>;
|
|
325
326
|
screenshot_label?: string;
|
|
327
|
+
screenshot_full_page?: boolean | null;
|
|
326
328
|
navigation_error?: string;
|
|
327
329
|
wait_error?: string;
|
|
328
330
|
}
|
package/dist/profile.js
CHANGED
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
resolveRiddleProofProfileTimeoutSec,
|
|
24
24
|
slugifyRiddleProofProfileName,
|
|
25
25
|
summarizeRiddleProofProfileResult
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-F46O7DP2.js";
|
|
27
27
|
export {
|
|
28
28
|
RIDDLE_PROOF_PROFILE_CHECK_TYPES,
|
|
29
29
|
RIDDLE_PROOF_PROFILE_EVIDENCE_VERSION,
|