Skip to content

Commit 73ea932

Browse files
committed
[chrome] small history fixes
1 parent 4791d3f commit 73ea932

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

packages/chrome/src/History.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,15 @@ export class History {
8282

8383
push(
8484
url: URL,
85+
title: string | null = null,
8586
state: any = null,
8687
navigate: boolean = true,
8788
virtual: boolean = false
8889
): HistoryState {
8990
if (this.index + 1 < this.states.length)
9091
// "fork" history tree, creating a new timeline
9192
this.states.splice(this.index, this.states.length - this.index);
92-
const hstate = new HistoryState({ url, state });
93+
const hstate = new HistoryState({ url, state, title });
9394
if (virtual) hstate.virtual = true;
9495

9596
if (url.href != "puter://newtab") browser.globalhistory.push(hstate);
@@ -106,11 +107,16 @@ export class History {
106107

107108
return this.states[this.index];
108109
}
109-
replace(url: URL, state: any, navigate: boolean = true): HistoryState {
110+
replace(
111+
url: URL,
112+
title: string | null,
113+
state: any,
114+
navigate: boolean = true
115+
): HistoryState {
110116
if (this.index < this.states.length) {
111117
this.current().url = url;
112118
this.current().state = state;
113-
this.current().title = null;
119+
this.current().title = title;
114120
this.current().favicon = null;
115121
} else {
116122
return this.push(url, state);
@@ -127,6 +133,7 @@ export class History {
127133
return this.states[this.index];
128134
}
129135
go(delta: number, navigate: boolean = true): HistoryState {
136+
const current = this.current();
130137
this.index += delta;
131138
if (this.index < 0) {
132139
this.index = 0;
@@ -135,8 +142,9 @@ export class History {
135142
}
136143

137144
let newstate = this.states[this.index];
145+
console.error("going", newstate);
138146

139-
if (newstate.virtual) {
147+
if (current.virtual) {
140148
sendFrame(this.tab, "popstate", {
141149
state: newstate.state,
142150
url: newstate.url.href,

packages/chrome/src/IsolatedFrame.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ const cfg = {
6868
syncxhr: false,
6969
strictRewrites: true,
7070
rewriterLogs: false,
71-
captureErrors: true,
71+
captureErrors: false,
7272
cleanErrors: false,
7373
scramitize: false,
7474
sourcemaps: true,
@@ -822,17 +822,19 @@ const chromemethods: ChromeboundMethods = {
822822

823823
history_go: async (tab, { delta }) => {
824824
if (tab) {
825+
console.error("hist go" + delta);
825826
tab.history.go(delta);
826827
}
827828
},
828-
history_pushState: async (tab, { url, title }) => {
829+
history_pushState: async (tab, { url, title, state }) => {
829830
if (tab) {
830-
tab.history.push(new URL(url), title, true);
831+
console.error("hist push", url);
832+
tab.history.push(new URL(url), title, state, false, true);
831833
}
832834
},
833-
history_replaceState: async (tab, { url, title }) => {
835+
history_replaceState: async (tab, { url, title, state }) => {
834836
if (tab) {
835-
tab.history.replace(new URL(url), title);
837+
tab.history.replace(new URL(url), title, state, false);
836838
}
837839
},
838840
};

0 commit comments

Comments
 (0)