mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-21 20:24:42 +00:00
add failing body.onload tests
This commit is contained in:
@@ -1,15 +1,15 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<body onload="loaded()"></body>
|
<body onload="loadEvent = event"></body>
|
||||||
<script src="../testing.js"></script>
|
<script src="../testing.js"></script>
|
||||||
|
|
||||||
<script id=bodyOnLoad2>
|
<script id=bodyOnLoad2>
|
||||||
let called = 0;
|
// Per spec, the handler is compiled as: function(event) { loadEvent = event }
|
||||||
function loaded(e) {
|
// Verify: handler fires, "event" parameter is a proper Event, and handler is a function.
|
||||||
called += 1;
|
let loadEvent = null;
|
||||||
}
|
|
||||||
|
|
||||||
testing.eventually(() => {
|
testing.eventually(() => {
|
||||||
testing.expectEqual(1, called);
|
testing.expectEqual("function", typeof document.body.onload);
|
||||||
|
testing.expectTrue(loadEvent instanceof Event);
|
||||||
|
testing.expectEqual("load", loadEvent.type);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
28
src/browser/tests/window/body_onload3.html
Normal file
28
src/browser/tests/window/body_onload3.html
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<body onload="called++"></body>
|
||||||
|
<script src="../testing.js"></script>
|
||||||
|
|
||||||
|
<script id=bodyOnLoad3>
|
||||||
|
// Per spec, the handler is compiled as: function(event) { called++ }
|
||||||
|
// Verify: handler fires exactly once, and body.onload reflects to window.onload.
|
||||||
|
let called = 0;
|
||||||
|
|
||||||
|
testing.eventually(() => {
|
||||||
|
// The attribute handler should have fired exactly once.
|
||||||
|
testing.expectEqual(1, called);
|
||||||
|
|
||||||
|
// body.onload is a Window-reflecting handler per spec.
|
||||||
|
testing.expectEqual("function", typeof document.body.onload);
|
||||||
|
testing.expectEqual(document.body.onload, window.onload);
|
||||||
|
|
||||||
|
// Setting body.onload via property replaces the attribute handler.
|
||||||
|
let propertyCalled = false;
|
||||||
|
document.body.onload = function() { propertyCalled = true; };
|
||||||
|
testing.expectEqual(document.body.onload, window.onload);
|
||||||
|
|
||||||
|
// Setting onload to null removes the handler.
|
||||||
|
document.body.onload = null;
|
||||||
|
testing.expectEqual(null, document.body.onload);
|
||||||
|
testing.expectEqual(null, window.onload);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
Reference in New Issue
Block a user