mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-12-14 23:38:57 +00:00
add location set hash tests
This commit is contained in:
@@ -52,7 +52,7 @@ pub const Location = struct {
|
|||||||
current_url;
|
current_url;
|
||||||
|
|
||||||
const normalized_hash = std.mem.trimStart(u8, hash, "#");
|
const normalized_hash = std.mem.trimStart(u8, hash, "#");
|
||||||
const new_url = try std.fmt.allocPrint(page.arena, "{s}#{s}", .{ base_without_hash, normalized_hash });
|
const new_url = try std.fmt.allocPrint(page.session.transfer_arena, "{s}#{s}", .{ base_without_hash, normalized_hash });
|
||||||
|
|
||||||
return page.navigateFromWebAPI(new_url, .{ .reason = .script }, .replace);
|
return page.navigateFromWebAPI(new_url, .{ .reason = .script }, .replace);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,3 +13,13 @@
|
|||||||
testing.expectEqual("9582", location.port);
|
testing.expectEqual("9582", location.port);
|
||||||
testing.expectEqual("", location.search);
|
testing.expectEqual("", location.search);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<script id=location_hash>
|
||||||
|
location.hash = "#abcdef";
|
||||||
|
testing.expectEqual("#abcdef", location.hash);
|
||||||
|
testing.expectEqual('http://localhost:9582/src/tests/html/location.html#abcdef', location.href);
|
||||||
|
|
||||||
|
location.hash = "xyzxyz";
|
||||||
|
testing.expectEqual("#xyzxyz", location.hash);
|
||||||
|
testing.expectEqual('http://localhost:9582/src/tests/html/location.html#xyzxyz', location.href);
|
||||||
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user