mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-02-04 14:33:47 +00:00
copy history test from legacy
This commit is contained in:
@@ -827,13 +827,6 @@ pub const Script = struct {
|
||||
return;
|
||||
}
|
||||
|
||||
// @ZIGDOM
|
||||
// if (page.delayed_navigation) {
|
||||
// // If we're navigating to another page, an error is expected
|
||||
// // since we probably terminated the script forcefully.
|
||||
// return;
|
||||
// }
|
||||
|
||||
const msg = try_catch.err(page.arena) catch |err| @errorName(err) orelse "unknown";
|
||||
log.warn(.js, "eval script", .{
|
||||
.url = url,
|
||||
|
||||
37
src/browser/tests/history.html
Normal file
37
src/browser/tests/history.html
Normal file
@@ -0,0 +1,37 @@
|
||||
<!DOCTYPE html>
|
||||
<script src="testing.js"></script>
|
||||
|
||||
<script id=history>
|
||||
testing.expectEqual('auto', history.scrollRestoration);
|
||||
|
||||
history.scrollRestoration = 'manual';
|
||||
testing.expectEqual('manual', history.scrollRestoration);
|
||||
|
||||
history.scrollRestoration = 'auto';
|
||||
testing.expectEqual('auto', history.scrollRestoration);
|
||||
testing.expectEqual(null, history.state)
|
||||
|
||||
history.pushState({ testInProgress: true }, null, 'http://127.0.0.1:9582/src/browser/tests/history_after_nav.skip.html');
|
||||
testing.expectEqual({ testInProgress: true }, history.state);
|
||||
|
||||
history.pushState({ testInProgress: false }, null, 'http://127.0.0.1:9582/xhr/json');
|
||||
history.replaceState({ "new": "field", testComplete: true }, null);
|
||||
|
||||
let state = { "new": "field", testComplete: true };
|
||||
testing.expectEqual(state, history.state);
|
||||
|
||||
let popstateEventFired = false;
|
||||
let popstateEventState = null;
|
||||
|
||||
window.addEventListener('popstate', (event) => {
|
||||
popstateEventFired = true;
|
||||
popstateEventState = event.state;
|
||||
});
|
||||
|
||||
testing.eventually(() => {
|
||||
testing.expectEqual(true, popstateEventFired);
|
||||
testing.expectEqual(state, popstateEventState);
|
||||
})
|
||||
|
||||
history.back();
|
||||
</script>
|
||||
6
src/browser/tests/history_after_nav.skip.html
Normal file
6
src/browser/tests/history_after_nav.skip.html
Normal file
@@ -0,0 +1,6 @@
|
||||
<!DOCTYPE html>
|
||||
<script src="testing.js"></script>
|
||||
|
||||
<script id=history-after-nav>
|
||||
testing.expectEqual(true, history.state && history.state.testInProgress);
|
||||
</script>
|
||||
@@ -123,3 +123,8 @@ pub const JsApi = struct {
|
||||
pub const forward = bridge.function(History.forward, .{});
|
||||
pub const go = bridge.function(History.go, .{});
|
||||
};
|
||||
|
||||
const testing = @import("../../testing.zig");
|
||||
test "WebApi: History" {
|
||||
try testing.htmlRunner("history.html", .{});
|
||||
}
|
||||
|
||||
@@ -405,7 +405,7 @@ fn runWebApiTest(test_file: [:0]const u8) !void {
|
||||
try page.navigate(url, .{});
|
||||
_ = test_session.wait(2000);
|
||||
|
||||
page._session.browser.runMicrotasks();
|
||||
test_browser.runMicrotasks();
|
||||
|
||||
js_context.eval("testing.assertOk()", "testing.assertOk()") catch |err| {
|
||||
const msg = try_catch.err(arena_allocator) catch @errorName(err) orelse "unknown";
|
||||
|
||||
Reference in New Issue
Block a user