fix navigation and related tests

This commit is contained in:
Muki Kiboigo
2025-10-10 04:02:42 -07:00
parent f97697535f
commit e9b08f19cf
14 changed files with 168 additions and 146 deletions

View File

@@ -51,14 +51,6 @@
// if we're already in a fail state, return fail, nothing can recover this
if (testing._status === 'fail') return 'fail';
if (testing._isSecondWait) {
for (const pw of (testing._onPageWait)) {
testing._captured = pw[1];
pw[0]();
testing._captured = null;
}
}
// run any eventually's that we've captured
for (const ev of testing._eventually) {
testing._captured = ev[1];
@@ -101,18 +93,6 @@
_registerErrorCallback();
}
// Set expectations to happen on the next time that `page.wait` is executed.
//
// History specifically uses this as it queues navigation that needs to be checked
// when the next page is loaded.
function onPageWait(fn) {
// Store callbacks to run when page.wait() happens
testing._onPageWait.push([fn, {
script_id: document.currentScript.id,
stack: new Error().stack,
}]);
}
async function async(promise, cb) {
const script_id = document.currentScript ? document.currentScript.id : '<script id is unavailable in browsers>';
const stack = new Error().stack;
@@ -192,15 +172,12 @@
window.testing = {
_status: 'empty',
_eventually: [],
_onPageWait: [],
_executed_scripts: new Set(),
_captured: null,
_isSecondWait: false,
skip: skip,
async: async,
getStatus: getStatus,
eventually: eventually,
onPageWait: onPageWait,
expectEqual: expectEqual,
expectError: expectError,
withError: withError,