Rename testing.eventually to testing.onload, to make it more clear

This commit is contained in:
Karl Seguin
2026-03-24 12:21:46 +08:00
parent c91eac17d0
commit dfd9f216bd
44 changed files with 97 additions and 97 deletions

View File

@@ -15,7 +15,7 @@
a1.play(); a1.play();
cb.push(a1.playState); cb.push(a1.playState);
}); });
testing.eventually(() => testing.expectEqual(['idle', 'running', 'finished', true], cb)); testing.onload(() => testing.expectEqual(['idle', 'running', 'finished', true], cb));
</script> </script>
<!-- <script id=startTime> <!-- <script id=startTime>
@@ -39,7 +39,7 @@
// onfinish callback should be scheduled and called asynchronously // onfinish callback should be scheduled and called asynchronously
a3.onfinish = function() { calls.push('finish'); }; a3.onfinish = function() { calls.push('finish'); };
a3.play(); a3.play();
testing.eventually(() => testing.expectEqual(['finish'], calls)); testing.onload(() => testing.expectEqual(['finish'], calls));
</script> </script>
<script id=pause> <script id=pause>
@@ -52,7 +52,7 @@
a4.pause(); a4.pause();
cb4.push(a4.playState) cb4.push(a4.playState)
}); });
testing.eventually(() => testing.expectEqual(['running', 'paused'], cb4)); testing.onload(() => testing.expectEqual(['running', 'paused'], cb4));
</script> </script>
<script id=finish> <script id=finish>
@@ -65,6 +65,6 @@
cb5.push(a5.playState); cb5.push(a5.playState);
a5.play(); a5.play();
}); });
testing.eventually(() => testing.expectEqual(['idle', 'finished'], cb5)); testing.onload(() => testing.expectEqual(['idle', 'finished'], cb5));
</script> </script>
--> -->

View File

@@ -71,7 +71,7 @@
document.fonts.load("italic bold 16px Roboto"); document.fonts.load("italic bold 16px Roboto");
testing.eventually(() => { testing.onload(() => {
testing.expectEqual(true, loading); testing.expectEqual(true, loading);
testing.expectEqual(true, loadingdone); testing.expectEqual(true, loadingdone);
}); });

View File

@@ -498,7 +498,7 @@
testing.expectEqual('.async-test', sheet.cssRules[0].selectorText); testing.expectEqual('.async-test', sheet.cssRules[0].selectorText);
replacedAsync = true; replacedAsync = true;
}); });
testing.eventually(() => testing.expectTrue(replacedAsync)); testing.onload(() => testing.expectTrue(replacedAsync));
} }
</script> </script>

View File

@@ -131,7 +131,7 @@
document.open(); document.open();
}, 5); }, 5);
testing.eventually(() => { testing.onload(() => {
// The element should be gone now // The element should be gone now
const afterOpen = document.getElementById('will_be_removed'); const afterOpen = document.getElementById('will_be_removed');
testing.expectEqual(null, afterOpen); testing.expectEqual(null, afterOpen);

View File

@@ -532,6 +532,6 @@
testing.expectEqual(true, result); testing.expectEqual(true, result);
}); });
testing.eventually(() => testing.expectEqual(true, asyncBlockDispatched)); testing.onload(() => testing.expectEqual(true, asyncBlockDispatched));
} }
</script> </script>

View File

@@ -139,7 +139,7 @@
}); });
}); });
testing.eventually(() => testing.expectEqual(true, result)); testing.onload(() => testing.expectEqual(true, result));
} }
</script> </script>
@@ -150,7 +150,7 @@
const img = document.createElement("img"); const img = document.createElement("img");
img.addEventListener("load", () => { fired = true; }); img.addEventListener("load", () => { fired = true; });
document.body.appendChild(img); document.body.appendChild(img);
testing.eventually(() => testing.expectEqual(false, fired)); testing.onload(() => testing.expectEqual(false, fired));
} }
</script> </script>
@@ -163,7 +163,7 @@
document.body.appendChild(img); document.body.appendChild(img);
img.src = "https://cdn.lightpanda.io/website/assets/images/docs/hn.png"; img.src = "https://cdn.lightpanda.io/website/assets/images/docs/hn.png";
testing.eventually(() => testing.expectEqual(true, result)); testing.onload(() => testing.expectEqual(true, result));
} }
</script> </script>

View File

@@ -210,7 +210,7 @@
}); });
input.setSelectionRange(1, 4); input.setSelectionRange(1, 4);
testing.eventually(() => { testing.onload(() => {
testing.expectEqual(5, eventCount); testing.expectEqual(5, eventCount);
testing.expectEqual('selectionchange', lastEvent.type); testing.expectEqual('selectionchange', lastEvent.type);
testing.expectEqual(input, lastEvent.target); testing.expectEqual(input, lastEvent.target);
@@ -247,7 +247,7 @@
input.select(); input.select();
testing.eventually(() => { testing.onload(() => {
testing.expectEqual(1, eventCount); testing.expectEqual(1, eventCount);
testing.expectEqual('select', lastEvent.type); testing.expectEqual('select', lastEvent.type);
testing.expectEqual(input, lastEvent.target); testing.expectEqual(input, lastEvent.target);

View File

@@ -54,7 +54,7 @@
link.rel = 'stylesheet'; link.rel = 'stylesheet';
link.addEventListener('load', () => { fired = true; }); link.addEventListener('load', () => { fired = true; });
document.head.appendChild(link); document.head.appendChild(link);
testing.eventually(() => testing.expectEqual(false, fired)); testing.onload(() => testing.expectEqual(false, fired));
} }
</script> </script>
@@ -66,7 +66,7 @@
link.href = 'https://lightpanda.io/opensource-browser/15'; link.href = 'https://lightpanda.io/opensource-browser/15';
link.addEventListener('load', () => { fired = true; }); link.addEventListener('load', () => { fired = true; });
document.head.appendChild(link); document.head.appendChild(link);
testing.eventually(() => testing.expectEqual(false, fired)); testing.onload(() => testing.expectEqual(false, fired));
} }
</script> </script>
@@ -81,7 +81,7 @@
// then set href. // then set href.
link.href = 'https://lightpanda.io/opensource-browser/15'; link.href = 'https://lightpanda.io/opensource-browser/15';
testing.eventually(() => testing.expectEqual(true, result)); testing.onload(() => testing.expectEqual(true, result));
} }
</script> </script>
@@ -98,7 +98,7 @@
}); });
testing.eventually(() => { testing.onload(() => {
results.forEach((r) => { results.forEach((r) => {
testing.expectEqual(true, r); testing.expectEqual(true, r);
}); });

View File

@@ -8,14 +8,14 @@
script1.async = false; script1.async = false;
script1.src = "dynamic1.js"; script1.src = "dynamic1.js";
document.getElementsByTagName('head')[0].appendChild(script1); document.getElementsByTagName('head')[0].appendChild(script1);
testing.eventually(() => { testing.onload(() => {
testing.expectEqual(1, loaded1); testing.expectEqual(1, loaded1);
}); });
</script> </script>
<script id=no_double_execute> <script id=no_double_execute>
document.getElementsByTagName('head')[0].appendChild(script1); document.getElementsByTagName('head')[0].appendChild(script1);
testing.eventually(() => { testing.onload(() => {
testing.expectEqual(1, loaded1); testing.expectEqual(1, loaded1);
}); });
</script> </script>
@@ -25,7 +25,7 @@
const script2a = document.createElement('script'); const script2a = document.createElement('script');
script2a.src = "dynamic2.js"; script2a.src = "dynamic2.js";
document.getElementsByTagName('head')[0].appendChild(script2a); document.getElementsByTagName('head')[0].appendChild(script2a);
testing.eventually(() => { testing.onload(() => {
testing.expectEqual(2, loaded2); testing.expectEqual(2, loaded2);
}); });
</script> </script>
@@ -38,7 +38,7 @@
</script> </script>
<script id=src_after_append> <script id=src_after_append>
testing.eventually(() => { testing.onload(() => {
testing.expectEqual(2, loaded2); testing.expectEqual(2, loaded2);
}); });
</script> </script>

View File

@@ -48,7 +48,7 @@
s6.type = 'module'; s6.type = 'module';
s6.textContent = 'window.module_executed = true;'; s6.textContent = 'window.module_executed = true;';
document.head.appendChild(s6); document.head.appendChild(s6);
testing.eventually(() => { testing.onload(() => {
testing.expectTrue(window.module_executed); testing.expectTrue(window.module_executed);
}); });
</script> </script>

View File

@@ -21,7 +21,7 @@
testing.expectEqual(testing.BASE_URL + 'element/html/script/empty.js', s.src); testing.expectEqual(testing.BASE_URL + 'element/html/script/empty.js', s.src);
document.head.appendChild(s); document.head.appendChild(s);
testing.eventually(() => { testing.onload(() => {
testing.expectEqual(true, dom_load); testing.expectEqual(true, dom_load);
testing.expectEqual(true, attribute_load); testing.expectEqual(true, attribute_load);
}); });

View File

@@ -427,7 +427,7 @@
div.setAttribute('slot', 'content'); div.setAttribute('slot', 'content');
host.appendChild(div); host.appendChild(div);
testing.eventually(() => { testing.onload(() => {
testing.expectEqual(1, calls); testing.expectEqual(1, calls);
}); });
} }
@@ -455,7 +455,7 @@
div.setAttribute('slot', 'other'); div.setAttribute('slot', 'other');
testing.eventually(() => { testing.onload(() => {
testing.expectEqual(1, calls); testing.expectEqual(1, calls);
}); });
} }
@@ -483,7 +483,7 @@
div.remove(); div.remove();
testing.eventually(() => { testing.onload(() => {
testing.expectEqual(1, calls); testing.expectEqual(1, calls);
}); });
} }
@@ -511,7 +511,7 @@
div.slot = 'other'; div.slot = 'other';
testing.eventually(() => { testing.onload(() => {
testing.expectEqual(1, calls); testing.expectEqual(1, calls);
}); });
} }

View File

@@ -128,7 +128,7 @@
}); });
}); });
testing.eventually(() => testing.expectEqual(true, result)); testing.onload(() => testing.expectEqual(true, result));
} }
</script> </script>

View File

@@ -256,7 +256,7 @@
textarea.select(); textarea.select();
testing.eventually(() => { testing.onload(() => {
testing.expectEqual(1, eventCount); testing.expectEqual(1, eventCount);
testing.expectEqual('select', lastEvent.type); testing.expectEqual('select', lastEvent.type);
testing.expectEqual(textarea, lastEvent.target); testing.expectEqual(textarea, lastEvent.target);
@@ -295,7 +295,7 @@
}); });
textarea.setSelectionRange(1, 4); textarea.setSelectionRange(1, 4);
testing.eventually(() => { testing.onload(() => {
testing.expectEqual(5, eventCount); testing.expectEqual(5, eventCount);
testing.expectEqual('selectionchange', lastEvent.type); testing.expectEqual('selectionchange', lastEvent.type);
testing.expectEqual(textarea, lastEvent.target); testing.expectEqual(textarea, lastEvent.target);

View File

@@ -242,7 +242,7 @@
<script id=abortsignal_timeout> <script id=abortsignal_timeout>
var s3 = AbortSignal.timeout(10); var s3 = AbortSignal.timeout(10);
testing.eventually(() => { testing.onload(() => {
testing.expectEqual(true, s3.aborted); testing.expectEqual(true, s3.aborted);
testing.expectEqual('TimeoutError', s3.reason); testing.expectEqual('TimeoutError', s3.reason);
testing.expectError('Error: TimeoutError', () => { testing.expectError('Error: TimeoutError', () => {

View File

@@ -61,7 +61,7 @@
window.postMessage('test data', '*'); window.postMessage('test data', '*');
testing.eventually(() => { testing.onload(() => {
testing.expectEqual('test data', receivedEvent.data); testing.expectEqual('test data', receivedEvent.data);
testing.expectEqual(window, receivedEvent.source); testing.expectEqual(window, receivedEvent.source);
testing.expectEqual('message', receivedEvent.type); testing.expectEqual('message', receivedEvent.type);
@@ -81,7 +81,7 @@
const testObj = { type: 'test', value: 123, nested: { key: 'value' } }; const testObj = { type: 'test', value: 123, nested: { key: 'value' } };
window.postMessage(testObj, '*'); window.postMessage(testObj, '*');
testing.eventually(() => { testing.onload(() => {
testing.expectEqual(testObj, receivedData); testing.expectEqual(testObj, receivedData);
}); });
} }
@@ -111,7 +111,7 @@
window.postMessage(42, '*'); window.postMessage(42, '*');
testing.eventually(() => { testing.onload(() => {
testing.expectEqual(42, received); testing.expectEqual(42, received);
}); });
} }
@@ -129,7 +129,7 @@
const arr = [1, 2, 3, 'test']; const arr = [1, 2, 3, 'test'];
window.postMessage(arr, '*'); window.postMessage(arr, '*');
testing.eventually(() => { testing.onload(() => {
testing.expectEqual(arr, received); testing.expectEqual(arr, received);
}); });
} }
@@ -146,7 +146,7 @@
window.postMessage(null, '*'); window.postMessage(null, '*');
testing.eventually(() => { testing.onload(() => {
testing.expectEqual(null, received); testing.expectEqual(null, received);
}); });
} }
@@ -163,7 +163,7 @@
window.postMessage('test', '*'); window.postMessage('test', '*');
testing.eventually(() => { testing.onload(() => {
testing.expectEqual('http://127.0.0.1:9582', receivedOrigin); testing.expectEqual('http://127.0.0.1:9582', receivedOrigin);
}); });
} }

View File

@@ -12,7 +12,7 @@
window.postMessage('trigger', '*'); window.postMessage('trigger', '*');
testing.eventually(() => { testing.onload(() => {
testing.expectEqual(2, count); testing.expectEqual(2, count);
}); });
} }

View File

@@ -28,7 +28,7 @@
$('#f2').src = 'support/sub2.html'; $('#f2').src = 'support/sub2.html';
testing.expectEqual(true, true); testing.expectEqual(true, true);
testing.eventually(() => { testing.onload(() => {
testing.expectEqual(undefined, window[20]); testing.expectEqual(undefined, window[20]);
testing.expectEqual(window, window[1].top); testing.expectEqual(window, window[1].top);
@@ -84,7 +84,7 @@
f3.src = 'invalid'; // still fires load! f3.src = 'invalid'; // still fires load!
document.documentElement.appendChild(f3); document.documentElement.appendChild(f3);
testing.eventually(() => { testing.onload(() => {
testing.expectEqual('f1_onload_loaded', window.f1_onload); testing.expectEqual('f1_onload_loaded', window.f1_onload);
testing.expectEqual(true, f3_load_event); testing.expectEqual(true, f3_load_event);
}); });
@@ -98,7 +98,7 @@
f4.src = "about:blank"; f4.src = "about:blank";
document.documentElement.appendChild(f4); document.documentElement.appendChild(f4);
testing.eventually(() => { testing.onload(() => {
testing.expectEqual("<html><head></head><body></body></html>", f4.contentDocument.documentElement.outerHTML); testing.expectEqual("<html><head></head><body></body></html>", f4.contentDocument.documentElement.outerHTML);
}); });
} }
@@ -112,7 +112,7 @@
document.documentElement.appendChild(f5); document.documentElement.appendChild(f5);
f5.src = "about:blank"; f5.src = "about:blank";
testing.eventually(() => { testing.onload(() => {
testing.expectEqual("<html><head></head><body></body></html>", f5.contentDocument.documentElement.outerHTML); testing.expectEqual("<html><head></head><body></body></html>", f5.contentDocument.documentElement.outerHTML);
}); });
} }
@@ -144,14 +144,14 @@
let i = document.createElement('iframe'); let i = document.createElement('iframe');
document.documentElement.appendChild(i); document.documentElement.appendChild(i);
i.contentWindow.location.href = 'support/page.html'; i.contentWindow.location.href = 'support/page.html';
testing.eventually(() => { testing.onload(() => {
testing.expectEqual('<html><head></head><body>a-page\n</body></html>', i.contentDocument.documentElement.outerHTML); testing.expectEqual('<html><head></head><body>a-page\n</body></html>', i.contentDocument.documentElement.outerHTML);
}); });
} }
</script> </script>
<script id=count> <script id=count>
testing.eventually(() => { testing.onload(() => {
testing.expectEqual(9, window.length); testing.expectEqual(9, window.length);
}); });
</script> </script>

View File

@@ -17,7 +17,7 @@
iframe.contentWindow.postMessage('ping', '*'); iframe.contentWindow.postMessage('ping', '*');
}); });
testing.eventually(() => { testing.onload(() => {
testing.expectEqual('pong', reply.data); testing.expectEqual('pong', reply.data);
testing.expectEqual(testing.ORIGIN, reply.origin); testing.expectEqual(testing.ORIGIN, reply.origin);
}); });

View File

@@ -5,7 +5,7 @@
<a id=l1 target=f1 href=support/page.html></a> <a id=l1 target=f1 href=support/page.html></a>
<script id=anchor> <script id=anchor>
$('#l1').click(); $('#l1').click();
testing.eventually(() => { testing.onload(() => {
testing.expectEqual('<html><head></head><body>a-page\n</body></html>', $('#frame1').contentDocument.documentElement.outerHTML); testing.expectEqual('<html><head></head><body>a-page\n</body></html>', $('#frame1').contentDocument.documentElement.outerHTML);
}); });
</script> </script>
@@ -21,7 +21,7 @@
form.action = 'support/page.html'; form.action = 'support/page.html';
form.submit(); form.submit();
testing.eventually(() => { testing.onload(() => {
testing.expectEqual('<html><head></head><body>a-page\n</body></html>', frame2.contentDocument.documentElement.outerHTML); testing.expectEqual('<html><head></head><body>a-page\n</body></html>', frame2.contentDocument.documentElement.outerHTML);
}); });
} }
@@ -35,7 +35,7 @@
<script id=formtarget> <script id=formtarget>
{ {
$('#submit1').click(); $('#submit1').click();
testing.eventually(() => { testing.onload(() => {
testing.expectEqual('<html><head></head><body>a-page\n</body></html>', $('#f3').contentDocument.documentElement.outerHTML); testing.expectEqual('<html><head></head><body>a-page\n</body></html>', $('#f3').contentDocument.documentElement.outerHTML);
}); });
} }

View File

@@ -8,7 +8,7 @@
// If support/history.html has a failed assertion, it'll log the error and // If support/history.html has a failed assertion, it'll log the error and
// stop the script. If it succeeds, it'll set support_history_completed // stop the script. If it succeeds, it'll set support_history_completed
// which we can use here to assume everything passed. // which we can use here to assume everything passed.
testing.eventually(() => { testing.onload(() => {
testing.expectEqual(true, window.support_history_completed); testing.expectEqual(true, window.support_history_completed);
testing.expectEqual(true, window.support_history_popstateEventFired); testing.expectEqual(true, window.support_history_popstateEventFired);
testing.expectEqual({testInProgress: true }, window.support_history_popstateEventState); testing.expectEqual({testInProgress: true }, window.support_history_popstateEventState);

View File

@@ -14,7 +14,7 @@
observer.observe(target); observer.observe(target);
testing.eventually(() => { testing.onload(() => {
testing.expectEqual(true, callbackCalled); testing.expectEqual(true, callbackCalled);
testing.expectEqual(1, entries.length); testing.expectEqual(1, entries.length);
@@ -41,7 +41,7 @@
count += 1; count += 1;
}).observe(div); }).observe(div);
testing.eventually(() => { testing.onload(() => {
testing.expectEqual(0, count); testing.expectEqual(0, count);
}); });
} }
@@ -56,7 +56,7 @@
}).observe(div1); }).observe(div1);
div2.appendChild(div1); div2.appendChild(div1);
testing.eventually(() => { testing.onload(() => {
testing.expectEqual(1, count); testing.expectEqual(1, count);
}); });
} }

View File

@@ -12,7 +12,7 @@
observer.observe(target); observer.observe(target);
testing.eventually(() => { testing.onload(() => {
testing.expectEqual(1, callCount); testing.expectEqual(1, callCount);
observer.disconnect(); observer.disconnect();
@@ -22,7 +22,7 @@
const observer2 = new IntersectionObserver(() => {}); const observer2 = new IntersectionObserver(() => {});
observer2.observe(target); observer2.observe(target);
testing.eventually(() => { testing.onload(() => {
observer2.disconnect(); observer2.disconnect();
testing.expectEqual(1, callCount); testing.expectEqual(1, callCount);
}); });

View File

@@ -19,7 +19,7 @@
observer.observe(target1); observer.observe(target1);
observer.observe(target2); observer.observe(target2);
testing.eventually(() => { testing.onload(() => {
testing.expectEqual(2, entryCount); testing.expectEqual(2, entryCount);
testing.expectTrue(seenTargets.has(target1)); testing.expectTrue(seenTargets.has(target1));
testing.expectTrue(seenTargets.has(target2)); testing.expectTrue(seenTargets.has(target2));

View File

@@ -20,7 +20,7 @@
observer.unobserve(target1); observer.unobserve(target1);
observer.observe(target2); observer.observe(target2);
testing.eventually(() => { testing.onload(() => {
// Should only see target2, not target1 // Should only see target2, not target1
testing.expectEqual(1, seenTargets.length); testing.expectEqual(1, seenTargets.length);
testing.expectEqual(target2, seenTargets[0]); testing.expectEqual(target2, seenTargets[0]);

View File

@@ -12,5 +12,5 @@
let replaced = false; let replaced = false;
css.replace('body{}').then(() => replaced = true); css.replace('body{}').then(() => replaced = true);
testing.eventually(() => testing.expectEqual(true, replaced)); testing.onload(() => testing.expectEqual(true, replaced));
</script> </script>

View File

@@ -11,5 +11,5 @@
cb.push('finished'); cb.push('finished');
cb.push(x == a1); cb.push(x == a1);
}); });
testing.eventually(() => testing.expectEqual(['finished', true], cb)); testing.onload(() => testing.expectEqual(['finished', true], cb));
</script> </script>

View File

@@ -11,7 +11,7 @@
count += 1; count += 1;
}).observe(div); }).observe(div);
testing.eventually(() => { testing.onload(() => {
testing.expectEqual(0, count); testing.expectEqual(0, count);
}); });
} }
@@ -27,7 +27,7 @@
}).observe(div1); }).observe(div1);
div2.appendChild(div1); div2.appendChild(div1);
testing.eventually(() => { testing.onload(() => {
testing.expectEqual(1, count); testing.expectEqual(1, count);
}); });
} }
@@ -51,7 +51,7 @@
observer.observe(div1); observer.observe(div1);
testing.expectEqual(0, count); testing.expectEqual(0, count);
testing.eventually(() => { testing.onload(() => {
testing.expectEqual(1, count); testing.expectEqual(1, count);
}); });
} }
@@ -75,7 +75,7 @@
testing.expectEqual(0, count); testing.expectEqual(0, count);
observer.unobserve(div1); observer.unobserve(div1);
testing.eventually(() => { testing.onload(() => {
testing.expectEqual(0, count); testing.expectEqual(0, count);
}); });
} }
@@ -100,7 +100,7 @@
testing.expectEqual(0, count); testing.expectEqual(0, count);
observer.disconnect(); observer.disconnect();
testing.eventually(() => { testing.onload(() => {
testing.expectEqual(0, count); testing.expectEqual(0, count);
}); });
} }
@@ -117,7 +117,7 @@
document.body.appendChild(div1); document.body.appendChild(div1);
new IntersectionObserver(entries => { entry = entries[0]; }).observe(div1); new IntersectionObserver(entries => { entry = entries[0]; }).observe(div1);
testing.eventually(() => { testing.onload(() => {
testing.expectEqual(125, entry.boundingClientRect.x); testing.expectEqual(125, entry.boundingClientRect.x);
testing.expectEqual(1, entry.intersectionRatio); testing.expectEqual(1, entry.intersectionRatio);
testing.expectEqual(125, entry.intersectionRect.x); testing.expectEqual(125, entry.intersectionRect.x);
@@ -150,7 +150,7 @@
observer.observe(div); observer.observe(div);
capture.push('post-observe'); capture.push('post-observe');
testing.eventually(() => { testing.onload(() => {
testing.expectEqual([ testing.expectEqual([
'pre-append', 'pre-append',
'post-append', 'post-append',

View File

@@ -31,7 +31,7 @@
<script id=timeout> <script id=timeout>
var s3 = AbortSignal.timeout(10); var s3 = AbortSignal.timeout(10);
testing.eventually(() => { testing.onload(() => {
testing.expectEqual(true, s3.aborted); testing.expectEqual(true, s3.aborted);
testing.expectEqual('TimeoutError', s3.reason); testing.expectEqual('TimeoutError', s3.reason);
testing.expectError('Error: TimeoutError', () => { testing.expectError('Error: TimeoutError', () => {

View File

@@ -28,7 +28,7 @@
popstateEventState = event.state; popstateEventState = event.state;
}); });
testing.eventually(() => { testing.onload(() => {
testing.expectEqual(true, popstateEventFired); testing.expectEqual(true, popstateEventFired);
testing.expectEqual(state, popstateEventState); testing.expectEqual(state, popstateEventState);
}) })

View File

@@ -14,7 +14,7 @@
popstateEventState = event.state; popstateEventState = event.state;
}; };
testing.eventually(() => { testing.onload(() => {
testing.expectEqual(true, popstateEventFired); testing.expectEqual(true, popstateEventFired);
testing.expectEqual(state, popstateEventState); testing.expectEqual(state, popstateEventState);
}) })

View File

@@ -24,5 +24,5 @@
// inline script should ignore defer and async attributes. If we don't do // inline script should ignore defer and async attributes. If we don't do
// this correctly, we'd end up in an infinite loop // this correctly, we'd end up in an infinite loop
// https://github.com/lightpanda-io/browser/issues/1014 // https://github.com/lightpanda-io/browser/issues/1014
testing.eventually(() => testing.expectEqual(2, dyn1_loaded)); testing.onload(() => testing.expectEqual(2, dyn1_loaded));
</script> </script>

View File

@@ -94,7 +94,7 @@
lp.appendChild(div); lp.appendChild(div);
testing.expectEqual(slot, div.assignedSlot); testing.expectEqual(slot, div.assignedSlot);
testing.eventually(() => { testing.onload(() => {
testing.expectEqual(1, calls) testing.expectEqual(1, calls)
}); });
} }
@@ -113,7 +113,7 @@
const div = $('#s2'); const div = $('#s2');
div.removeAttribute('slot'); div.removeAttribute('slot');
testing.eventually(() => { testing.onload(() => {
testing.expectEqual(1, calls) testing.expectEqual(1, calls)
}); });
} }
@@ -132,7 +132,7 @@
const div = $('#s3'); const div = $('#s3');
div.slot = 'other'; div.slot = 'other';
testing.eventually(() => { testing.onload(() => {
testing.expectEqual(1, calls) testing.expectEqual(1, calls)
}); });
} }
@@ -154,7 +154,7 @@
div.slot = 'other'; div.slot = 'other';
lp.appendChild(div); lp.appendChild(div);
div.slot = 'slot-1' div.slot = 'slot-1'
testing.eventually(() => { testing.onload(() => {
testing.expectEqual(1, calls) testing.expectEqual(1, calls)
}); });
} }
@@ -172,7 +172,7 @@
}); });
$('#s5').remove(); $('#s5').remove();
testing.eventually(() => { testing.onload(() => {
testing.expectEqual(1, calls) testing.expectEqual(1, calls)
}); });
} }

View File

@@ -16,7 +16,7 @@
start = timestamp; start = timestamp;
} }
requestAnimationFrame(step); requestAnimationFrame(step);
testing.eventually(() => { testing.onload(() => {
testing.expectEqual(true, start > 0) testing.expectEqual(true, start > 0)
}); });
@@ -24,23 +24,23 @@
start = 0; start = 0;
}); });
cancelAnimationFrame(request_id); cancelAnimationFrame(request_id);
testing.eventually(() => testing.expectEqual(true, start > 0)); testing.onload(() => testing.expectEqual(true, start > 0));
</script> </script>
<script id=setTimeout> <script id=setTimeout>
let longCall = false; let longCall = false;
window.setTimeout(() => {longCall = true}, 5001); window.setTimeout(() => {longCall = true}, 5001);
testing.eventually(() => testing.expectEqual(false, longCall)); testing.onload(() => testing.expectEqual(false, longCall));
let wst1 = 0; let wst1 = 0;
window.setTimeout(() => {wst1 += 1}, 1); window.setTimeout(() => {wst1 += 1}, 1);
testing.eventually(() => testing.expectEqual(1, wst1)); testing.onload(() => testing.expectEqual(1, wst1));
let wst2 = 1; let wst2 = 1;
window.setTimeout((a, b) => { window.setTimeout((a, b) => {
wst2 = a + b; wst2 = a + b;
}, 1, 2, 3); }, 1, 2, 3);
testing.eventually(() => testing.expectEqual(5, wst2)); testing.onload(() => testing.expectEqual(5, wst2));
</script> </script>
<script id=eventTarget> <script id=eventTarget>
@@ -70,7 +70,7 @@
<script id=queueMicroTask> <script id=queueMicroTask>
var qm = false; var qm = false;
window.queueMicrotask(() => {qm = true }); window.queueMicrotask(() => {qm = true });
testing.eventually(() => testing.expectEqual(true, qm)); testing.onload(() => testing.expectEqual(true, qm));
</script> </script>
<script id=DOMContentLoaded> <script id=DOMContentLoaded>
@@ -79,7 +79,7 @@
window.addEventListener('DOMContentLoaded', (e) => { window.addEventListener('DOMContentLoaded', (e) => {
dcl = e.target == document; dcl = e.target == document;
}); });
testing.eventually(() => testing.expectEqual(true, dcl)); testing.onload(() => testing.expectEqual(true, dcl));
</script> </script>
<script id=window.onload> <script id=window.onload>
@@ -97,7 +97,7 @@
window.onload = callback; window.onload = callback;
testing.expectEqual(callback, window.onload); testing.expectEqual(callback, window.onload);
testing.eventually(() => testing.expectEqual(true, isDocumentTarget)); testing.onload(() => testing.expectEqual(true, isDocumentTarget));
</script> </script>
<script id=reportError> <script id=reportError>

View File

@@ -12,7 +12,7 @@
document.body.appendChild(iframe); document.body.appendChild(iframe);
iframe.src = blob_url; iframe.src = blob_url;
testing.eventually(() => { testing.onload(() => {
testing.expectEqual('Hello Blob', iframe.contentDocument.getElementById('test').textContent); testing.expectEqual('Hello Blob', iframe.contentDocument.getElementById('test').textContent);
}); });
} }
@@ -33,7 +33,7 @@
document.body.appendChild(iframe2); document.body.appendChild(iframe2);
iframe2.src = url2; iframe2.src = url2;
testing.eventually(() => { testing.onload(() => {
testing.expectEqual('First', iframe1.contentDocument.body.textContent); testing.expectEqual('First', iframe1.contentDocument.body.textContent);
testing.expectEqual('Second', iframe2.contentDocument.body.textContent); testing.expectEqual('Second', iframe2.contentDocument.body.textContent);
}); });

View File

@@ -9,7 +9,7 @@
call1 = true; call1 = true;
}); });
testing.eventually(() => { testing.onload(() => {
testing.expectEqual(document, ex1.target); testing.expectEqual(document, ex1.target);
testing.expectEqual('DOMContentLoaded', ex1.type); testing.expectEqual('DOMContentLoaded', ex1.type);
testing.expectEqual(true, call1); testing.expectEqual(true, call1);

View File

@@ -86,7 +86,7 @@
// With buffered: true, existing marks should be delivered // With buffered: true, existing marks should be delivered
observer.observe({ type: "mark", buffered: true }); observer.observe({ type: "mark", buffered: true });
testing.eventually(() => { testing.onload(() => {
testing.expectEqual(true, receivedEntries !== null); testing.expectEqual(true, receivedEntries !== null);
testing.expectEqual(2, receivedEntries.length); testing.expectEqual(2, receivedEntries.length);
testing.expectEqual("early1", receivedEntries[0].name); testing.expectEqual("early1", receivedEntries[0].name);

View File

@@ -582,7 +582,7 @@
document.removeEventListener('selectionchange', listener); document.removeEventListener('selectionchange', listener);
textNode.textContent = "The quick brown fox"; textNode.textContent = "The quick brown fox";
testing.eventually(() => { testing.onload(() => {
testing.expectEqual(14, eventCount); testing.expectEqual(14, eventCount);
testing.expectEqual('selectionchange', lastEvent.type); testing.expectEqual('selectionchange', lastEvent.type);
testing.expectEqual(document, lastEvent.target); testing.expectEqual(document, lastEvent.target);

View File

@@ -52,10 +52,10 @@
throw new Error('no error'); throw new Error('no error');
} }
function eventually(cb) { function onload(cb) {
const script_id = _currentScriptId(); const script_id = _currentScriptId();
if (!script_id) { if (!script_id) {
throw new Error('testing.eventually called outside of a script'); throw new Error('testing.onload called outside of a script');
} }
eventuallies.push({ eventuallies.push({
callback: cb, callback: cb,
@@ -110,7 +110,7 @@
expectEqual: expectEqual, expectEqual: expectEqual,
expectError: expectError, expectError: expectError,
withError: withError, withError: withError,
eventually: eventually, onload: onload,
IS_TEST_RUNNER: IS_TEST_RUNNER, IS_TEST_RUNNER: IS_TEST_RUNNER,
HOST: '127.0.0.1', HOST: '127.0.0.1',
ORIGIN: 'http://127.0.0.1:9582', ORIGIN: 'http://127.0.0.1:9582',

View File

@@ -10,7 +10,7 @@
testing.expectEqual(window, e.currentTarget); testing.expectEqual(window, e.currentTarget);
} }
testing.eventually(() => { testing.onload(() => {
testing.expectEqual(1, called); testing.expectEqual(1, called);
}); });
</script> </script>

View File

@@ -7,7 +7,7 @@
// Verify: handler fires, "event" parameter is a proper Event, and handler is a function. // Verify: handler fires, "event" parameter is a proper Event, and handler is a function.
let loadEvent = null; let loadEvent = null;
testing.eventually(() => { testing.onload(() => {
testing.expectEqual("function", typeof document.body.onload); testing.expectEqual("function", typeof document.body.onload);
testing.expectTrue(loadEvent instanceof Event); testing.expectTrue(loadEvent instanceof Event);
testing.expectEqual("load", loadEvent.type); testing.expectEqual("load", loadEvent.type);

View File

@@ -7,7 +7,7 @@
// Verify: handler fires exactly once, and body.onload reflects to window.onload. // Verify: handler fires exactly once, and body.onload reflects to window.onload.
let called = 0; let called = 0;
testing.eventually(() => { testing.onload(() => {
// The attribute handler should have fired exactly once. // The attribute handler should have fired exactly once.
testing.expectEqual(1, called); testing.expectEqual(1, called);

View File

@@ -17,7 +17,7 @@
testing.expectEqual(true, timer1 != timer2); testing.expectEqual(true, timer1 != timer2);
testing.eventually(() => { testing.onload(() => {
testing.expectEqual(true, set_interval1); testing.expectEqual(true, set_interval1);
testing.expectEqual(false, set_interval2); testing.expectEqual(false, set_interval2);
}); });
@@ -29,7 +29,7 @@
window.setTimeout((a, b) => { window.setTimeout((a, b) => {
wst2 = a + b; wst2 = a + b;
}, 1, 2, 3); }, 1, 2, 3);
testing.eventually(() => testing.expectEqual(5, wst2)); testing.onload(() => testing.expectEqual(5, wst2));
</script> </script>
<script id=invalid-timer-clear> <script id=invalid-timer-clear>

View File

@@ -43,7 +43,7 @@
// noop // noop
window.removeEventListener('load', fn); window.removeEventListener('load', fn);
testing.eventually(() => { testing.onload(() => {
testing.expectEqual(1, call1); testing.expectEqual(1, call1);
testing.expectEqual(2, call2); testing.expectEqual(2, call2);
}); });
@@ -285,6 +285,6 @@
unhandledCalled += 1; unhandledCalled += 1;
}); });
Promise.reject({x: 'Fail'}); Promise.reject({x: 'Fail'});
testing.eventually(() => testing.expectEqual(2, unhandledCalled)); testing.onload(() => testing.expectEqual(2, unhandledCalled));
} }
</script> </script>