playwright-core 1.45.0 → 1.45.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/server/browserContext.js +4 -3
- package/lib/server/chromium/crBrowser.js +2 -2
- package/lib/server/chromium/crPage.js +17 -17
- package/lib/server/firefox/ffBrowser.js +2 -2
- package/lib/server/firefox/ffPage.js +7 -4
- package/lib/server/page.js +19 -3
- package/lib/server/webkit/wkBrowser.js +1 -1
- package/lib/server/webkit/wkPage.js +3 -3
- package/lib/vite/traceViewer/assets/{codeMirrorModule-CPAFaJ_C.js → codeMirrorModule-BfR9u_dG.js} +14 -14
- package/lib/vite/traceViewer/assets/{testServerConnection-PVj2W_fj.js → testServerConnection-CLJOcN3M.js} +3 -3
- package/lib/vite/traceViewer/{index.Crz_aqo6.js → index.D7JIa5vL.js} +1 -1
- package/lib/vite/traceViewer/index.html +2 -2
- package/lib/vite/traceViewer/{uiMode.8uXvBaZc.js → uiMode.DGx1ltIi.js} +1 -1
- package/lib/vite/traceViewer/uiMode.html +2 -2
- package/package.json +1 -1
|
@@ -314,9 +314,10 @@ class BrowserContext extends _instrumentation.SdkObject {
|
|
|
314
314
|
password: password || ''
|
|
315
315
|
};
|
|
316
316
|
}
|
|
317
|
-
async addInitScript(
|
|
318
|
-
|
|
319
|
-
|
|
317
|
+
async addInitScript(source) {
|
|
318
|
+
const initScript = new _page6.InitScript(source);
|
|
319
|
+
this.initScripts.push(initScript);
|
|
320
|
+
await this.doAddInitScript(initScript);
|
|
320
321
|
}
|
|
321
322
|
async _removeInitScripts() {
|
|
322
323
|
this.initScripts.splice(0, this.initScripts.length);
|
|
@@ -415,8 +415,8 @@ class CRBrowserContext extends _browserContext.BrowserContext {
|
|
|
415
415
|
for (const page of this.pages()) await page._delegate.updateHttpCredentials();
|
|
416
416
|
for (const sw of this.serviceWorkers()) await sw.updateHttpCredentials();
|
|
417
417
|
}
|
|
418
|
-
async doAddInitScript(
|
|
419
|
-
for (const page of this.pages()) await page._delegate.addInitScript(
|
|
418
|
+
async doAddInitScript(initScript) {
|
|
419
|
+
for (const page of this.pages()) await page._delegate.addInitScript(initScript);
|
|
420
420
|
}
|
|
421
421
|
async doRemoveInitScripts() {
|
|
422
422
|
for (const page of this.pages()) await page._delegate.removeInitScripts();
|
|
@@ -221,8 +221,8 @@ class CRPage {
|
|
|
221
221
|
goForward() {
|
|
222
222
|
return this._go(+1);
|
|
223
223
|
}
|
|
224
|
-
async addInitScript(
|
|
225
|
-
await this._forAllFrameSessions(frame => frame._evaluateOnNewDocument(
|
|
224
|
+
async addInitScript(initScript, world = 'main') {
|
|
225
|
+
await this._forAllFrameSessions(frame => frame._evaluateOnNewDocument(initScript, world));
|
|
226
226
|
}
|
|
227
227
|
async removeInitScripts() {
|
|
228
228
|
await this._forAllFrameSessions(frame => frame._removeEvaluatesOnNewDocument());
|
|
@@ -429,6 +429,17 @@ class FrameSession {
|
|
|
429
429
|
this._handleFrameTree(frameTree);
|
|
430
430
|
this._addRendererListeners();
|
|
431
431
|
}
|
|
432
|
+
const localFrames = this._isMainFrame() ? this._page.frames() : [this._page._frameManager.frame(this._targetId)];
|
|
433
|
+
for (const frame of localFrames) {
|
|
434
|
+
// Note: frames might be removed before we send these.
|
|
435
|
+
this._client._sendMayFail('Page.createIsolatedWorld', {
|
|
436
|
+
frameId: frame._id,
|
|
437
|
+
grantUniveralAccess: true,
|
|
438
|
+
worldName: UTILITY_WORLD_NAME
|
|
439
|
+
});
|
|
440
|
+
for (const binding of this._crPage._browserContext._pageBindings.values()) frame.evaluateExpression(binding.source).catch(e => {});
|
|
441
|
+
for (const initScript of this._crPage._browserContext.initScripts) frame.evaluateExpression(initScript.source).catch(e => {});
|
|
442
|
+
}
|
|
432
443
|
const isInitialEmptyPage = this._isMainFrame() && this._page.mainFrame().url() === ':';
|
|
433
444
|
if (isInitialEmptyPage) {
|
|
434
445
|
// Ignore lifecycle events, worlds and bindings for the initial empty page. It is never the final page
|
|
@@ -438,17 +449,6 @@ class FrameSession {
|
|
|
438
449
|
this._eventListeners.push(_eventsHelper.eventsHelper.addEventListener(this._client, 'Page.lifecycleEvent', event => this._onLifecycleEvent(event)));
|
|
439
450
|
});
|
|
440
451
|
} else {
|
|
441
|
-
const localFrames = this._isMainFrame() ? this._page.frames() : [this._page._frameManager.frame(this._targetId)];
|
|
442
|
-
for (const frame of localFrames) {
|
|
443
|
-
// Note: frames might be removed before we send these.
|
|
444
|
-
this._client._sendMayFail('Page.createIsolatedWorld', {
|
|
445
|
-
frameId: frame._id,
|
|
446
|
-
grantUniveralAccess: true,
|
|
447
|
-
worldName: UTILITY_WORLD_NAME
|
|
448
|
-
});
|
|
449
|
-
for (const binding of this._crPage._browserContext._pageBindings.values()) frame.evaluateExpression(binding.source).catch(e => {});
|
|
450
|
-
for (const source of this._crPage._browserContext.initScripts) frame.evaluateExpression(source).catch(e => {});
|
|
451
|
-
}
|
|
452
452
|
this._firstNonInitialNavigationCommittedFulfill();
|
|
453
453
|
this._eventListeners.push(_eventsHelper.eventsHelper.addEventListener(this._client, 'Page.lifecycleEvent', event => this._onLifecycleEvent(event)));
|
|
454
454
|
}
|
|
@@ -488,8 +488,8 @@ class FrameSession {
|
|
|
488
488
|
promises.push(this._updateEmulateMedia());
|
|
489
489
|
promises.push(this._updateFileChooserInterception(true));
|
|
490
490
|
for (const binding of this._crPage._page.allBindings()) promises.push(this._initBinding(binding));
|
|
491
|
-
for (const
|
|
492
|
-
for (const
|
|
491
|
+
for (const initScript of this._crPage._browserContext.initScripts) promises.push(this._evaluateOnNewDocument(initScript, 'main'));
|
|
492
|
+
for (const initScript of this._crPage._page.initScripts) promises.push(this._evaluateOnNewDocument(initScript, 'main'));
|
|
493
493
|
if (screencastOptions) promises.push(this._startVideoRecording(screencastOptions));
|
|
494
494
|
}
|
|
495
495
|
promises.push(this._client.send('Runtime.runIfWaitingForDebugger'));
|
|
@@ -970,12 +970,12 @@ class FrameSession {
|
|
|
970
970
|
enabled
|
|
971
971
|
}).catch(() => {}); // target can be closed.
|
|
972
972
|
}
|
|
973
|
-
async _evaluateOnNewDocument(
|
|
973
|
+
async _evaluateOnNewDocument(initScript, world) {
|
|
974
974
|
const worldName = world === 'utility' ? UTILITY_WORLD_NAME : undefined;
|
|
975
975
|
const {
|
|
976
976
|
identifier
|
|
977
977
|
} = await this._client.send('Page.addScriptToEvaluateOnNewDocument', {
|
|
978
|
-
source,
|
|
978
|
+
source: initScript.source,
|
|
979
979
|
worldName
|
|
980
980
|
});
|
|
981
981
|
this._evaluateOnNewDocumentIdentifiers.push(identifier);
|
|
@@ -374,11 +374,11 @@ class FFBrowserContext extends _browserContext.BrowserContext {
|
|
|
374
374
|
credentials
|
|
375
375
|
});
|
|
376
376
|
}
|
|
377
|
-
async doAddInitScript(
|
|
377
|
+
async doAddInitScript(initScript) {
|
|
378
378
|
await this._browser.session.send('Browser.setInitScripts', {
|
|
379
379
|
browserContextId: this._browserContextId,
|
|
380
380
|
scripts: this.initScripts.map(script => ({
|
|
381
|
-
script
|
|
381
|
+
script: script.source
|
|
382
382
|
}))
|
|
383
383
|
});
|
|
384
384
|
}
|
|
@@ -81,7 +81,7 @@ class FFPage {
|
|
|
81
81
|
});
|
|
82
82
|
// Ideally, we somehow ensure that utility world is created before Page.ready arrives, but currently it is racy.
|
|
83
83
|
// Therefore, we can end up with an initialized page without utility world, although very unlikely.
|
|
84
|
-
this.addInitScript('', UTILITY_WORLD_NAME).catch(e => this._markAsError(e));
|
|
84
|
+
this.addInitScript(new _page.InitScript(''), UTILITY_WORLD_NAME).catch(e => this._markAsError(e));
|
|
85
85
|
}
|
|
86
86
|
potentiallyUninitializedPage() {
|
|
87
87
|
return this._page;
|
|
@@ -369,13 +369,16 @@ class FFPage {
|
|
|
369
369
|
});
|
|
370
370
|
return success;
|
|
371
371
|
}
|
|
372
|
-
async addInitScript(
|
|
372
|
+
async addInitScript(initScript, worldName) {
|
|
373
373
|
this._initScripts.push({
|
|
374
|
-
|
|
374
|
+
initScript,
|
|
375
375
|
worldName
|
|
376
376
|
});
|
|
377
377
|
await this._session.send('Page.setInitScripts', {
|
|
378
|
-
scripts: this._initScripts
|
|
378
|
+
scripts: this._initScripts.map(s => ({
|
|
379
|
+
script: s.initScript.source,
|
|
380
|
+
worldName: s.worldName
|
|
381
|
+
}))
|
|
379
382
|
});
|
|
380
383
|
}
|
|
381
384
|
async removeInitScripts() {
|
package/lib/server/page.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.Worker = exports.PageBinding = exports.Page = void 0;
|
|
6
|
+
exports.Worker = exports.PageBinding = exports.Page = exports.InitScript = void 0;
|
|
7
7
|
var frames = _interopRequireWildcard(require("./frames"));
|
|
8
8
|
var input = _interopRequireWildcard(require("./input"));
|
|
9
9
|
var js = _interopRequireWildcard(require("./javascript"));
|
|
@@ -383,8 +383,9 @@ class Page extends _instrumentation.SdkObject {
|
|
|
383
383
|
await this._delegate.bringToFront();
|
|
384
384
|
}
|
|
385
385
|
async addInitScript(source) {
|
|
386
|
-
|
|
387
|
-
|
|
386
|
+
const initScript = new InitScript(source);
|
|
387
|
+
this.initScripts.push(initScript);
|
|
388
|
+
await this._delegate.addInitScript(initScript);
|
|
388
389
|
}
|
|
389
390
|
async _removeInitScripts() {
|
|
390
391
|
this.initScripts.splice(0, this.initScripts.length);
|
|
@@ -750,6 +751,21 @@ function addPageBinding(bindingName, needsHandle, utilityScriptSerializers) {
|
|
|
750
751
|
};
|
|
751
752
|
globalThis[bindingName].__installed = true;
|
|
752
753
|
}
|
|
754
|
+
class InitScript {
|
|
755
|
+
constructor(source) {
|
|
756
|
+
this.source = void 0;
|
|
757
|
+
const guid = (0, _utils.createGuid)();
|
|
758
|
+
this.source = `(() => {
|
|
759
|
+
globalThis.__pwInitScripts = globalThis.__pwInitScripts || {};
|
|
760
|
+
const hasInitScript = globalThis.__pwInitScripts[${JSON.stringify(guid)}];
|
|
761
|
+
if (hasInitScript)
|
|
762
|
+
return;
|
|
763
|
+
globalThis.__pwInitScripts[${JSON.stringify(guid)}] = true;
|
|
764
|
+
${source}
|
|
765
|
+
})();`;
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
exports.InitScript = InitScript;
|
|
753
769
|
class FrameThrottler {
|
|
754
770
|
constructor(nonThrottledFrames, defaultInterval, throttlingInterval) {
|
|
755
771
|
this._acks = [];
|
|
@@ -279,7 +279,7 @@ class WKBrowserContext extends _browserContext.BrowserContext {
|
|
|
279
279
|
this._options.httpCredentials = httpCredentials;
|
|
280
280
|
for (const page of this.pages()) await page._delegate.updateHttpCredentials();
|
|
281
281
|
}
|
|
282
|
-
async doAddInitScript(
|
|
282
|
+
async doAddInitScript(initScript) {
|
|
283
283
|
for (const page of this.pages()) await page._delegate._updateBootstrapScript();
|
|
284
284
|
}
|
|
285
285
|
async doRemoveInitScripts() {
|
|
@@ -756,7 +756,7 @@ class WKPage {
|
|
|
756
756
|
async removeExposedBindings() {
|
|
757
757
|
await this._updateBootstrapScript();
|
|
758
758
|
}
|
|
759
|
-
async addInitScript(
|
|
759
|
+
async addInitScript(initScript) {
|
|
760
760
|
await this._updateBootstrapScript();
|
|
761
761
|
}
|
|
762
762
|
async removeInitScripts() {
|
|
@@ -772,8 +772,8 @@ class WKPage {
|
|
|
772
772
|
scripts.push('if (!window.safari) window.safari = { pushNotification: { toString() { return "[object SafariRemoteNotification]"; } } };');
|
|
773
773
|
scripts.push('if (!window.GestureEvent) window.GestureEvent = function GestureEvent() {};');
|
|
774
774
|
for (const binding of this._page.allBindings()) scripts.push(binding.source);
|
|
775
|
-
scripts.push(...this._browserContext.initScripts);
|
|
776
|
-
scripts.push(...this._page.initScripts);
|
|
775
|
+
scripts.push(...this._browserContext.initScripts.map(s => s.source));
|
|
776
|
+
scripts.push(...this._page.initScripts.map(s => s.source));
|
|
777
777
|
return scripts.join(';\n');
|
|
778
778
|
}
|
|
779
779
|
async _updateBootstrapScript() {
|