Skip to content

Commit 7822d43

Browse files
committed
[frontend] route history.back/forward/go() through browser history emulation
1 parent 6715e05 commit 7822d43

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

frontend/src/History.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,27 @@ export function injectHistoryEmulation(client: ScramjetClient, tab: Tab) {
159159
ctx.return(undefined);
160160
},
161161
});
162+
client.Proxy("History.prototype.back", {
163+
apply(ctx) {
164+
console.log("HISTORY BACK", ctx);
165+
tab.history.go(-1);
166+
ctx.return(undefined);
167+
},
168+
});
169+
client.Proxy("History.prototype.forward", {
170+
apply(ctx) {
171+
console.log("HISTORY FORWARD", ctx);
172+
tab.history.go(1);
173+
ctx.return(undefined);
174+
},
175+
});
176+
client.Proxy("History.prototype.go", {
177+
apply(ctx) {
178+
console.log("HISTORY GO", ctx);
179+
tab.history.go(ctx.args[0]);
180+
ctx.return(undefined);
181+
},
182+
});
162183
}
163184

164185
export function handleNavigate() {}

0 commit comments

Comments
 (0)