Skip to content

Commit 7a02da8

Browse files
authored
Merge pull request #685 from CodinGame/lmn/fix-undetected-reload
[FIX] Properly detect page reload when in sandbox mode
2 parents a0d8db7 + 60fe21a commit 7a02da8

1 file changed

Lines changed: 59 additions & 1 deletion

File tree

vscode-patches/0071-feat-support-loading-VSCode-in-an-iframe.patch

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ Subject: [PATCH] feat: support loading VSCode in an iframe
99
src/vs/base/browser/window.ts | 7 +++-
1010
src/vs/workbench/browser/window.ts | 25 ++++++++----
1111
.../browser/view/renderers/webviewPreloads.ts | 4 +-
12+
.../performance/browser/perfviewEditor.ts | 3 +-
13+
.../performance/browser/startupTimings.ts | 3 +-
1214
.../browser/webWorkerExtensionHost.ts | 6 +--
13-
6 files changed, 44 insertions(+), 41 deletions(-)
15+
.../lifecycle/browser/lifecycleService.ts | 2 +-
16+
9 files changed, 49 insertions(+), 44 deletions(-)
1417

1518
diff --git a/src/vs/base/browser/dom.ts b/src/vs/base/browser/dom.ts
1619
index 0ee97e64713..7162381400e 100644
@@ -220,6 +223,48 @@ index 2aa027c29ba..b9753110764 100644
220223
if (!root.adoptedStyleSheets.includes(tokenizationStyle)) {
221224
root.adoptedStyleSheets.push(tokenizationStyle);
222225
}
226+
diff --git a/src/vs/workbench/contrib/performance/browser/perfviewEditor.ts b/src/vs/workbench/contrib/performance/browser/perfviewEditor.ts
227+
index 3f45789a32f..f05c8cc3c4e 100644
228+
--- a/src/vs/workbench/contrib/performance/browser/perfviewEditor.ts
229+
+++ b/src/vs/workbench/contrib/performance/browser/perfviewEditor.ts
230+
@@ -31,6 +31,7 @@ import { Registry } from '../../../../platform/registry/common/platform.js';
231+
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions, getWorkbenchContribution } from '../../../common/contributions.js';
232+
import { ICustomEditorLabelService } from '../../../services/editor/common/customEditorLabelService.js';
233+
import { IRemoteAgentService } from '../../../services/remote/common/remoteAgentService.js';
234+
+import { mainWindow } from '../../../../base/browser/window.js';
235+
236+
export class PerfviewContrib {
237+
238+
@@ -308,7 +309,7 @@ class PerfModelContentProvider implements ITextModelContentProvider {
239+
}
240+
241+
private _addResourceTimingStats(md: MarkdownBuilder) {
242+
- const stats = performance.getEntriesByType('resource').map(entry => {
243+
+ const stats = mainWindow.performance.getEntriesByType('resource').map(entry => {
244+
return [entry.name, entry.duration];
245+
});
246+
if (!stats.length) {
247+
diff --git a/src/vs/workbench/contrib/performance/browser/startupTimings.ts b/src/vs/workbench/contrib/performance/browser/startupTimings.ts
248+
index eb0a9ffbc42..b6a71a21ce4 100644
249+
--- a/src/vs/workbench/contrib/performance/browser/startupTimings.ts
250+
+++ b/src/vs/workbench/contrib/performance/browser/startupTimings.ts
251+
@@ -19,6 +19,7 @@ import { ITimerService } from '../../../services/timer/browser/timerService.js';
252+
import { IWorkbenchContribution } from '../../../common/contributions.js';
253+
import { posix } from '../../../../base/common/path.js';
254+
import { hash } from '../../../../base/common/hash.js';
255+
+import { mainWindow } from '../../../../base/browser/window.js';
256+
257+
export abstract class StartupTimings {
258+
259+
@@ -121,7 +122,7 @@ export class BrowserResourcePerformanceMarks {
260+
name: { classification: 'SystemMetaData'; purpose: 'PerformanceAndHealth'; comment: 'Resource basename' };
261+
duration: { classification: 'SystemMetaData'; purpose: 'PerformanceAndHealth'; comment: 'Resource duration' };
262+
};
263+
- for (const item of performance.getEntriesByType('resource')) {
264+
+ for (const item of mainWindow.performance.getEntriesByType('resource')) {
265+
266+
try {
267+
const url = new URL(item.name);
223268
diff --git a/src/vs/workbench/services/extensions/browser/webWorkerExtensionHost.ts b/src/vs/workbench/services/extensions/browser/webWorkerExtensionHost.ts
224269
index d42138bea2e..24068d0cd76 100644
225270
--- a/src/vs/workbench/services/extensions/browser/webWorkerExtensionHost.ts
@@ -248,3 +293,16 @@ index d42138bea2e..24068d0cd76 100644
248293
};
249294

250295
const protocol: IMessagePassingProtocol = {
296+
diff --git a/src/vs/workbench/services/lifecycle/browser/lifecycleService.ts b/src/vs/workbench/services/lifecycle/browser/lifecycleService.ts
297+
index 5bacc9fad6b..36f6d7776ed 100644
298+
--- a/src/vs/workbench/services/lifecycle/browser/lifecycleService.ts
299+
+++ b/src/vs/workbench/services/lifecycle/browser/lifecycleService.ts
300+
@@ -208,7 +208,7 @@ export class BrowserLifecycleService extends AbstractLifecycleService {
301+
protected override doResolveStartupKind(): StartupKind | undefined {
302+
let startupKind = super.doResolveStartupKind();
303+
if (typeof startupKind !== 'number') {
304+
- const timing = performance.getEntriesByType('navigation').at(0) as PerformanceNavigationTiming | undefined;
305+
+ const timing = mainWindow.performance.getEntriesByType('navigation').at(0) as PerformanceNavigationTiming | undefined;
306+
if (timing?.type === 'reload') {
307+
// MDN: https://developer.mozilla.org/en-US/docs/Web/API/PerformanceNavigationTiming/type#value
308+
startupKind = StartupKind.ReloadedWindow;

0 commit comments

Comments
 (0)