chromium-bidi 0.5.20 → 0.5.21
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/.browser +1 -1
- package/lib/THIRD_PARTY_NOTICES +1 -1
- package/lib/cjs/bidiMapper/modules/cdp/CdpTarget.d.ts +1 -1
- package/lib/cjs/bidiMapper/modules/cdp/CdpTarget.js +32 -3
- package/lib/cjs/bidiMapper/modules/cdp/CdpTarget.js.map +1 -1
- package/lib/cjs/bidiMapper/modules/cdp/CdpTargetManager.js +14 -2
- package/lib/cjs/bidiMapper/modules/cdp/CdpTargetManager.js.map +1 -1
- package/lib/cjs/bidiMapper/modules/context/BrowsingContextImpl.d.ts +1 -1
- package/lib/cjs/bidiMapper/modules/context/BrowsingContextImpl.js +28 -14
- package/lib/cjs/bidiMapper/modules/context/BrowsingContextImpl.js.map +1 -1
- package/lib/cjs/bidiMapper/modules/context/BrowsingContextProcessor.js +1 -0
- package/lib/cjs/bidiMapper/modules/context/BrowsingContextProcessor.js.map +1 -1
- package/lib/cjs/bidiMapper/modules/input/InputSource.d.ts +5 -5
- package/lib/cjs/bidiMapper/modules/network/NetworkProcessor.d.ts +1 -0
- package/lib/cjs/bidiMapper/modules/network/NetworkProcessor.js +9 -0
- package/lib/cjs/bidiMapper/modules/network/NetworkProcessor.js.map +1 -1
- package/lib/cjs/bidiMapper/modules/network/NetworkUtils.js +5 -2
- package/lib/cjs/bidiMapper/modules/network/NetworkUtils.js.map +1 -1
- package/lib/cjs/bidiMapper/modules/storage/StorageProcessor.js +2 -2
- package/lib/cjs/bidiMapper/modules/storage/StorageProcessor.js.map +1 -1
- package/lib/cjs/utils/Deferred.d.ts +1 -0
- package/lib/cjs/utils/Deferred.js +8 -0
- package/lib/cjs/utils/Deferred.js.map +1 -1
- package/lib/iife/mapperTab.js +127 -46
- package/lib/iife/mapperTab.js.map +1 -1
- package/package.json +19 -19
package/lib/iife/mapperTab.js
CHANGED
|
@@ -169,9 +169,9 @@ var mapperTab = (function () {
|
|
|
169
169
|
*/
|
|
170
170
|
Object.defineProperty(ProcessingQueue$1, "__esModule", { value: true });
|
|
171
171
|
ProcessingQueue$1.ProcessingQueue = void 0;
|
|
172
|
-
const log_js_1$
|
|
172
|
+
const log_js_1$e = log$1;
|
|
173
173
|
class ProcessingQueue {
|
|
174
|
-
static LOGGER_PREFIX = `${log_js_1$
|
|
174
|
+
static LOGGER_PREFIX = `${log_js_1$e.LogType.debug}:queue`;
|
|
175
175
|
#logger;
|
|
176
176
|
#processor;
|
|
177
177
|
#queue = [];
|
|
@@ -201,13 +201,13 @@ var mapperTab = (function () {
|
|
|
201
201
|
await entryPromise
|
|
202
202
|
.then((entry) => {
|
|
203
203
|
if (entry.kind === 'error') {
|
|
204
|
-
this.#logger?.(log_js_1$
|
|
204
|
+
this.#logger?.(log_js_1$e.LogType.debugError, 'Event threw before sending:', entry.error.message, entry.error.stack);
|
|
205
205
|
return;
|
|
206
206
|
}
|
|
207
207
|
return this.#processor(entry.value);
|
|
208
208
|
})
|
|
209
209
|
.catch((error) => {
|
|
210
|
-
this.#logger?.(log_js_1$
|
|
210
|
+
this.#logger?.(log_js_1$e.LogType.debugError, 'Event was not processed:', error?.message);
|
|
211
211
|
});
|
|
212
212
|
}
|
|
213
213
|
this.#isProcessing = false;
|
|
@@ -938,6 +938,7 @@ var mapperTab = (function () {
|
|
|
938
938
|
url: 'about:blank',
|
|
939
939
|
newWindow,
|
|
940
940
|
browserContextId: userContext === 'default' ? undefined : userContext,
|
|
941
|
+
background: params.background === true,
|
|
941
942
|
});
|
|
942
943
|
}
|
|
943
944
|
catch (err) {
|
|
@@ -3402,9 +3403,12 @@ var mapperTab = (function () {
|
|
|
3402
3403
|
path: params.cookie.path ?? '/',
|
|
3403
3404
|
secure: params.cookie.secure ?? false,
|
|
3404
3405
|
httpOnly: params.cookie.httpOnly ?? false,
|
|
3405
|
-
// CDP's `partitionKey` is the BiDi's `partition.sourceOrigin`.
|
|
3406
3406
|
...(partitionKey.sourceOrigin !== undefined && {
|
|
3407
|
-
partitionKey:
|
|
3407
|
+
partitionKey: {
|
|
3408
|
+
hasCrossSiteAncestor: false,
|
|
3409
|
+
// CDP's `partitionKey.topLevelSite` is the BiDi's `partition.sourceOrigin`.
|
|
3410
|
+
topLevelSite: partitionKey.sourceOrigin,
|
|
3411
|
+
},
|
|
3408
3412
|
}),
|
|
3409
3413
|
...(params.cookie.expiry !== undefined && {
|
|
3410
3414
|
expires: params.cookie.expiry,
|
|
@@ -3522,6 +3526,11 @@ var mapperTab = (function () {
|
|
|
3522
3526
|
if (params.url !== undefined) {
|
|
3523
3527
|
NetworkProcessor.parseUrlString(params.url);
|
|
3524
3528
|
}
|
|
3529
|
+
if (params.method !== undefined) {
|
|
3530
|
+
if (!NetworkProcessor.isMethodValid(params.method)) {
|
|
3531
|
+
throw new protocol_js_1$h.InvalidArgumentException(`Method '${method}' is invalid.`);
|
|
3532
|
+
}
|
|
3533
|
+
}
|
|
3525
3534
|
if (params.headers) {
|
|
3526
3535
|
NetworkProcessor.validateHeaders(params.headers);
|
|
3527
3536
|
}
|
|
@@ -3709,6 +3718,10 @@ var mapperTab = (function () {
|
|
|
3709
3718
|
}
|
|
3710
3719
|
}
|
|
3711
3720
|
}
|
|
3721
|
+
static isMethodValid(method) {
|
|
3722
|
+
// https://httpwg.org/specs/rfc9110.html#method.overview
|
|
3723
|
+
return /^[!#$%&'*+\-.^_`|~a-zA-Z\d]+$/.test(method);
|
|
3724
|
+
}
|
|
3712
3725
|
/**
|
|
3713
3726
|
* Attempts to parse the given url.
|
|
3714
3727
|
* Throws an InvalidArgumentException if the url is invalid.
|
|
@@ -3985,7 +3998,7 @@ var mapperTab = (function () {
|
|
|
3985
3998
|
Object.defineProperty(ChannelProxy$1, "__esModule", { value: true });
|
|
3986
3999
|
ChannelProxy$1.ChannelProxy = void 0;
|
|
3987
4000
|
const protocol_js_1$f = protocol;
|
|
3988
|
-
const log_js_1$
|
|
4001
|
+
const log_js_1$d = log$1;
|
|
3989
4002
|
const uuid_js_1$3 = uuid;
|
|
3990
4003
|
/**
|
|
3991
4004
|
* Used to send messages from realm to BiDi user.
|
|
@@ -4015,7 +4028,7 @@ var mapperTab = (function () {
|
|
|
4015
4028
|
void this.#startListener(realm, channelHandle, eventManager);
|
|
4016
4029
|
}
|
|
4017
4030
|
catch (error) {
|
|
4018
|
-
this.#logger?.(log_js_1$
|
|
4031
|
+
this.#logger?.(log_js_1$d.LogType.debugError, error);
|
|
4019
4032
|
}
|
|
4020
4033
|
}
|
|
4021
4034
|
/**
|
|
@@ -4122,7 +4135,7 @@ var mapperTab = (function () {
|
|
|
4122
4135
|
catch (error) {
|
|
4123
4136
|
// If an error is thrown, then the channel is permanently broken, so we
|
|
4124
4137
|
// exit the loop.
|
|
4125
|
-
this.#logger?.(log_js_1$
|
|
4138
|
+
this.#logger?.(log_js_1$d.LogType.debugError, error);
|
|
4126
4139
|
break;
|
|
4127
4140
|
}
|
|
4128
4141
|
}
|
|
@@ -4481,7 +4494,7 @@ var mapperTab = (function () {
|
|
|
4481
4494
|
StorageProcessor$1.StorageProcessor = void 0;
|
|
4482
4495
|
const protocol_js_1$d = protocol;
|
|
4483
4496
|
const assert_js_1$3 = assert$1;
|
|
4484
|
-
const log_js_1$
|
|
4497
|
+
const log_js_1$c = log$1;
|
|
4485
4498
|
const NetworkProcessor_js_1$1 = NetworkProcessor$1;
|
|
4486
4499
|
const NetworkUtils_js_1$2 = NetworkUtils;
|
|
4487
4500
|
/**
|
|
@@ -4517,7 +4530,7 @@ var mapperTab = (function () {
|
|
|
4517
4530
|
// `sourceOrigin` partition key, only cookies with the requested source origin
|
|
4518
4531
|
// are returned.
|
|
4519
4532
|
(c) => partitionKey.sourceOrigin === undefined ||
|
|
4520
|
-
c.partitionKey === partitionKey.sourceOrigin)
|
|
4533
|
+
c.partitionKey?.topLevelSite === partitionKey.sourceOrigin)
|
|
4521
4534
|
.filter((cdpCookie) => {
|
|
4522
4535
|
const bidiCookie = (0, NetworkUtils_js_1$2.cdpToBiDiCookie)(cdpCookie);
|
|
4523
4536
|
return this.#matchCookie(bidiCookie, params.filter);
|
|
@@ -4556,7 +4569,7 @@ var mapperTab = (function () {
|
|
|
4556
4569
|
// `sourceOrigin` partition key, only cookies with the requested source origin
|
|
4557
4570
|
// are returned.
|
|
4558
4571
|
(c) => partitionKey.sourceOrigin === undefined ||
|
|
4559
|
-
c.partitionKey === partitionKey.sourceOrigin)
|
|
4572
|
+
c.partitionKey?.topLevelSite === partitionKey.sourceOrigin)
|
|
4560
4573
|
.map((c) => (0, NetworkUtils_js_1$2.cdpToBiDiCookie)(c))
|
|
4561
4574
|
.filter((c) => this.#matchCookie(c, params.filter));
|
|
4562
4575
|
return {
|
|
@@ -4578,7 +4591,7 @@ var mapperTab = (function () {
|
|
|
4578
4591
|
// If the user context is not found, special error is thrown.
|
|
4579
4592
|
throw new protocol_js_1$d.NoSuchUserContextException(err.message);
|
|
4580
4593
|
}
|
|
4581
|
-
this.#logger?.(log_js_1$
|
|
4594
|
+
this.#logger?.(log_js_1$c.LogType.debugError, err);
|
|
4582
4595
|
throw new protocol_js_1$d.UnableToSetCookieException(err.toString());
|
|
4583
4596
|
}
|
|
4584
4597
|
return {
|
|
@@ -4629,7 +4642,7 @@ var mapperTab = (function () {
|
|
|
4629
4642
|
}
|
|
4630
4643
|
}
|
|
4631
4644
|
if (unsupportedPartitionKeys.size > 0) {
|
|
4632
|
-
this.#logger?.(log_js_1$
|
|
4645
|
+
this.#logger?.(log_js_1$c.LogType.debugInfo, `Unsupported partition keys: ${JSON.stringify(Object.fromEntries(unsupportedPartitionKeys))}`);
|
|
4633
4646
|
}
|
|
4634
4647
|
// Set `userContext` to `default` if not provided, as it's required in Chromium.
|
|
4635
4648
|
const userContext = descriptor.userContext ?? 'default';
|
|
@@ -4744,7 +4757,7 @@ var mapperTab = (function () {
|
|
|
4744
4757
|
CommandProcessor$1.CommandProcessor = void 0;
|
|
4745
4758
|
const protocol_js_1$c = protocol;
|
|
4746
4759
|
const EventEmitter_js_1$3 = EventEmitter$1;
|
|
4747
|
-
const log_js_1$
|
|
4760
|
+
const log_js_1$b = log$1;
|
|
4748
4761
|
const BidiNoOpParser_js_1 = BidiNoOpParser$1;
|
|
4749
4762
|
const BrowserProcessor_js_1 = BrowserProcessor$1;
|
|
4750
4763
|
const CdpProcessor_js_1 = CdpProcessor$1;
|
|
@@ -4945,7 +4958,7 @@ var mapperTab = (function () {
|
|
|
4945
4958
|
}
|
|
4946
4959
|
else {
|
|
4947
4960
|
const error = e;
|
|
4948
|
-
this.#logger?.(log_js_1$
|
|
4961
|
+
this.#logger?.(log_js_1$b.LogType.bidi, error);
|
|
4949
4962
|
this.emit("response" /* CommandProcessorEvents.Response */, {
|
|
4950
4963
|
message: OutgoingMessage_js_1$1.OutgoingMessage.createResolved(new protocol_js_1$c.UnknownErrorException(error.message, error.stack).toErrorResponse(command.id), command.channel),
|
|
4951
4964
|
event: command.method,
|
|
@@ -4983,11 +4996,18 @@ var mapperTab = (function () {
|
|
|
4983
4996
|
class Deferred {
|
|
4984
4997
|
#isFinished = false;
|
|
4985
4998
|
#promise;
|
|
4999
|
+
#result;
|
|
4986
5000
|
#resolve;
|
|
4987
5001
|
#reject;
|
|
4988
5002
|
get isFinished() {
|
|
4989
5003
|
return this.#isFinished;
|
|
4990
5004
|
}
|
|
5005
|
+
get result() {
|
|
5006
|
+
if (!this.#isFinished) {
|
|
5007
|
+
throw new Error('Deferred is not finished yet');
|
|
5008
|
+
}
|
|
5009
|
+
return this.#result;
|
|
5010
|
+
}
|
|
4991
5011
|
constructor() {
|
|
4992
5012
|
this.#promise = new Promise((resolve, reject) => {
|
|
4993
5013
|
this.#resolve = resolve;
|
|
@@ -5006,6 +5026,7 @@ var mapperTab = (function () {
|
|
|
5006
5026
|
return this.#promise.catch(onRejected);
|
|
5007
5027
|
}
|
|
5008
5028
|
resolve(value) {
|
|
5029
|
+
this.#result = value;
|
|
5009
5030
|
if (!this.#isFinished) {
|
|
5010
5031
|
this.#isFinished = true;
|
|
5011
5032
|
this.#resolve(value);
|
|
@@ -5057,7 +5078,7 @@ var mapperTab = (function () {
|
|
|
5057
5078
|
Object.defineProperty(Realm$1, "__esModule", { value: true });
|
|
5058
5079
|
Realm$1.Realm = void 0;
|
|
5059
5080
|
const protocol_js_1$b = protocol;
|
|
5060
|
-
const log_js_1$
|
|
5081
|
+
const log_js_1$a = log$1;
|
|
5061
5082
|
const uuid_js_1$1 = uuid;
|
|
5062
5083
|
const ChannelProxy_js_1 = ChannelProxy$1;
|
|
5063
5084
|
class Realm {
|
|
@@ -5091,7 +5112,7 @@ var mapperTab = (function () {
|
|
|
5091
5112
|
}
|
|
5092
5113
|
else {
|
|
5093
5114
|
// No need to await for the object to be released.
|
|
5094
|
-
void this.#releaseObject(objectId).catch((error) => this.#logger?.(log_js_1$
|
|
5115
|
+
void this.#releaseObject(objectId).catch((error) => this.#logger?.(log_js_1$a.LogType.debugError, error));
|
|
5095
5116
|
}
|
|
5096
5117
|
}
|
|
5097
5118
|
return bidiValue;
|
|
@@ -5759,11 +5780,11 @@ var mapperTab = (function () {
|
|
|
5759
5780
|
const protocol_js_1$9 = protocol;
|
|
5760
5781
|
const assert_js_1$2 = assert$1;
|
|
5761
5782
|
const Deferred_js_1$2 = Deferred$1;
|
|
5762
|
-
const log_js_1$
|
|
5783
|
+
const log_js_1$9 = log$1;
|
|
5763
5784
|
const unitConversions_js_1 = unitConversions;
|
|
5764
5785
|
const WindowRealm_js_1$1 = WindowRealm$1;
|
|
5765
5786
|
class BrowsingContextImpl {
|
|
5766
|
-
static LOGGER_PREFIX = `${log_js_1$
|
|
5787
|
+
static LOGGER_PREFIX = `${log_js_1$9.LogType.debug}:browsingContext`;
|
|
5767
5788
|
/** The ID of this browsing context. */
|
|
5768
5789
|
#id;
|
|
5769
5790
|
userContext;
|
|
@@ -5782,16 +5803,17 @@ var mapperTab = (function () {
|
|
|
5782
5803
|
#navigation = {
|
|
5783
5804
|
withinDocument: new Deferred_js_1$2.Deferred(),
|
|
5784
5805
|
};
|
|
5785
|
-
#url
|
|
5806
|
+
#url;
|
|
5786
5807
|
#eventManager;
|
|
5787
5808
|
#realmStorage;
|
|
5788
5809
|
#loaderId;
|
|
5789
5810
|
#cdpTarget;
|
|
5790
|
-
|
|
5811
|
+
// The deferred will be resolved when the default realm is created.
|
|
5812
|
+
#defaultRealmDeferred = new Deferred_js_1$2.Deferred();
|
|
5791
5813
|
#logger;
|
|
5792
5814
|
// Keeps track of the previously set viewport.
|
|
5793
5815
|
#previousViewport = { width: 0, height: 0 };
|
|
5794
|
-
constructor(id, parentId, userContext, cdpTarget, eventManager, browsingContextStorage, realmStorage, logger) {
|
|
5816
|
+
constructor(id, parentId, userContext, cdpTarget, eventManager, browsingContextStorage, realmStorage, url, logger) {
|
|
5795
5817
|
this.#cdpTarget = cdpTarget;
|
|
5796
5818
|
this.#id = id;
|
|
5797
5819
|
this.#parentId = parentId;
|
|
@@ -5800,9 +5822,10 @@ var mapperTab = (function () {
|
|
|
5800
5822
|
this.#browsingContextStorage = browsingContextStorage;
|
|
5801
5823
|
this.#realmStorage = realmStorage;
|
|
5802
5824
|
this.#logger = logger;
|
|
5825
|
+
this.#url = url;
|
|
5803
5826
|
}
|
|
5804
|
-
static create(id, parentId, userContext, cdpTarget, eventManager, browsingContextStorage, realmStorage, logger) {
|
|
5805
|
-
const context = new BrowsingContextImpl(id, parentId, userContext, cdpTarget, eventManager, browsingContextStorage, realmStorage, logger);
|
|
5827
|
+
static create(id, parentId, userContext, cdpTarget, eventManager, browsingContextStorage, realmStorage, url, logger) {
|
|
5828
|
+
const context = new BrowsingContextImpl(id, parentId, userContext, cdpTarget, eventManager, browsingContextStorage, realmStorage, url, logger);
|
|
5806
5829
|
context.#initListeners();
|
|
5807
5830
|
browsingContextStorage.addContext(context);
|
|
5808
5831
|
if (!context.isTopLevelContext()) {
|
|
@@ -5893,10 +5916,6 @@ var mapperTab = (function () {
|
|
|
5893
5916
|
#deleteAllChildren() {
|
|
5894
5917
|
this.directChildren.map((child) => child.dispose());
|
|
5895
5918
|
}
|
|
5896
|
-
get #defaultRealm() {
|
|
5897
|
-
(0, assert_js_1$2.assert)(this.#maybeDefaultRealm, `No default realm for browsing context ${this.#id}`);
|
|
5898
|
-
return this.#maybeDefaultRealm;
|
|
5899
|
-
}
|
|
5900
5919
|
get cdpTarget() {
|
|
5901
5920
|
return this.#cdpTarget;
|
|
5902
5921
|
}
|
|
@@ -5918,7 +5937,8 @@ var mapperTab = (function () {
|
|
|
5918
5937
|
}
|
|
5919
5938
|
async getOrCreateSandbox(sandbox) {
|
|
5920
5939
|
if (sandbox === undefined || sandbox === '') {
|
|
5921
|
-
return
|
|
5940
|
+
// Default realm is not guaranteed to be created at this point, so return a deferred.
|
|
5941
|
+
return await this.#defaultRealmDeferred;
|
|
5922
5942
|
}
|
|
5923
5943
|
let maybeSandboxes = this.#realmStorage.findRealms({
|
|
5924
5944
|
browsingContextId: this.id,
|
|
@@ -6066,7 +6086,13 @@ var mapperTab = (function () {
|
|
|
6066
6086
|
sandbox = name;
|
|
6067
6087
|
// Sandbox should have the same origin as the context itself, but in CDP
|
|
6068
6088
|
// it has an empty one.
|
|
6069
|
-
|
|
6089
|
+
if (!this.#defaultRealmDeferred.isFinished) {
|
|
6090
|
+
this.#logger?.(log_js_1$9.LogType.debugError, 'Unexpectedly, isolated realm created before the default one');
|
|
6091
|
+
}
|
|
6092
|
+
origin = this.#defaultRealmDeferred.isFinished
|
|
6093
|
+
? this.#defaultRealmDeferred.result.origin
|
|
6094
|
+
: // This fallback is not expected to be ever reached.
|
|
6095
|
+
'';
|
|
6070
6096
|
break;
|
|
6071
6097
|
case 'default':
|
|
6072
6098
|
origin = serializeOrigin(params.context.origin);
|
|
@@ -6076,7 +6102,7 @@ var mapperTab = (function () {
|
|
|
6076
6102
|
}
|
|
6077
6103
|
const realm = new WindowRealm_js_1$1.WindowRealm(this.id, this.#browsingContextStorage, this.#cdpTarget.cdpClient, this.#eventManager, id, this.#logger, origin, uniqueId, this.#realmStorage, sandbox);
|
|
6078
6104
|
if (auxData.isDefault) {
|
|
6079
|
-
this.#
|
|
6105
|
+
this.#defaultRealmDeferred.resolve(realm);
|
|
6080
6106
|
// Initialize ChannelProxy listeners for all the channels of all the
|
|
6081
6107
|
// preload scripts related to this BrowsingContext.
|
|
6082
6108
|
// TODO: extend for not default realms by the sandbox name.
|
|
@@ -6086,12 +6112,21 @@ var mapperTab = (function () {
|
|
|
6086
6112
|
}
|
|
6087
6113
|
});
|
|
6088
6114
|
this.#cdpTarget.cdpClient.on('Runtime.executionContextDestroyed', (params) => {
|
|
6115
|
+
if (this.#defaultRealmDeferred.isFinished &&
|
|
6116
|
+
this.#defaultRealmDeferred.result.executionContextId ===
|
|
6117
|
+
params.executionContextId) {
|
|
6118
|
+
this.#defaultRealmDeferred = new Deferred_js_1$2.Deferred();
|
|
6119
|
+
}
|
|
6089
6120
|
this.#realmStorage.deleteRealms({
|
|
6090
6121
|
cdpSessionId: this.#cdpTarget.cdpSessionId,
|
|
6091
6122
|
executionContextId: params.executionContextId,
|
|
6092
6123
|
});
|
|
6093
6124
|
});
|
|
6094
6125
|
this.#cdpTarget.cdpClient.on('Runtime.executionContextsCleared', () => {
|
|
6126
|
+
if (!this.#defaultRealmDeferred.isFinished) {
|
|
6127
|
+
this.#defaultRealmDeferred.reject(new protocol_js_1$9.UnknownErrorException('execution contexts cleared'));
|
|
6128
|
+
}
|
|
6129
|
+
this.#defaultRealmDeferred = new Deferred_js_1$2.Deferred();
|
|
6095
6130
|
this.#realmStorage.deleteRealms({
|
|
6096
6131
|
cdpSessionId: this.#cdpTarget.cdpSessionId,
|
|
6097
6132
|
});
|
|
@@ -6491,7 +6526,7 @@ var mapperTab = (function () {
|
|
|
6491
6526
|
}
|
|
6492
6527
|
async locateNodes(params) {
|
|
6493
6528
|
// TODO: create a dedicated sandbox instead of `#defaultRealm`.
|
|
6494
|
-
return await this.#locateNodesByLocator(this.#
|
|
6529
|
+
return await this.#locateNodesByLocator(await this.#defaultRealmDeferred, params.locator, params.startNodes ?? [], params.maxNodeCount, params.serializationOptions);
|
|
6495
6530
|
}
|
|
6496
6531
|
async #getLocatorDelegate(realm, locator, maxNodeCount, startNodes) {
|
|
6497
6532
|
switch (locator.type) {
|
|
@@ -6660,7 +6695,7 @@ var mapperTab = (function () {
|
|
|
6660
6695
|
}
|
|
6661
6696
|
// The next two commands cause a11y caches for the target to be
|
|
6662
6697
|
// preserved. We probably do not need to disable them if the
|
|
6663
|
-
// client is using a11y features but we could by calling
|
|
6698
|
+
// client is using a11y features, but we could by calling
|
|
6664
6699
|
// Accessibility.disable.
|
|
6665
6700
|
await Promise.all([
|
|
6666
6701
|
this.#cdpTarget.cdpClient.sendCommand('Accessibility.enable'),
|
|
@@ -7136,7 +7171,7 @@ var mapperTab = (function () {
|
|
|
7136
7171
|
Object.defineProperty(LogManager$1, "__esModule", { value: true });
|
|
7137
7172
|
LogManager$1.LogManager = void 0;
|
|
7138
7173
|
const protocol_js_1$8 = protocol;
|
|
7139
|
-
const log_js_1$
|
|
7174
|
+
const log_js_1$8 = log$1;
|
|
7140
7175
|
const logHelper_js_1 = logHelper;
|
|
7141
7176
|
/** Converts CDP StackTrace object to BiDi StackTrace object. */
|
|
7142
7177
|
function getBidiStackTrace(cdpStackTrace) {
|
|
@@ -7188,7 +7223,7 @@ var mapperTab = (function () {
|
|
|
7188
7223
|
});
|
|
7189
7224
|
if (realm === undefined) {
|
|
7190
7225
|
// Ignore exceptions not attached to any realm.
|
|
7191
|
-
this.#logger?.(log_js_1$
|
|
7226
|
+
this.#logger?.(log_js_1$8.LogType.cdp, params);
|
|
7192
7227
|
return;
|
|
7193
7228
|
}
|
|
7194
7229
|
const argsPromise = realm === undefined
|
|
@@ -7227,7 +7262,7 @@ var mapperTab = (function () {
|
|
|
7227
7262
|
});
|
|
7228
7263
|
if (realm === undefined) {
|
|
7229
7264
|
// Ignore exceptions not attached to any realm.
|
|
7230
|
-
this.#logger?.(log_js_1$
|
|
7265
|
+
this.#logger?.(log_js_1$8.LogType.cdp, params);
|
|
7231
7266
|
return;
|
|
7232
7267
|
}
|
|
7233
7268
|
for (const browsingContext of realm.associatedBrowsingContexts) {
|
|
@@ -7268,17 +7303,21 @@ var mapperTab = (function () {
|
|
|
7268
7303
|
CdpTarget$1.CdpTarget = void 0;
|
|
7269
7304
|
const chromium_bidi_js_1 = chromiumBidi;
|
|
7270
7305
|
const Deferred_js_1$1 = Deferred$1;
|
|
7306
|
+
const log_js_1$7 = log$1;
|
|
7307
|
+
const BrowsingContextImpl_js_1$1 = BrowsingContextImpl$1;
|
|
7271
7308
|
const LogManager_js_1 = LogManager$1;
|
|
7272
7309
|
class CdpTarget {
|
|
7273
7310
|
#id;
|
|
7274
7311
|
#cdpClient;
|
|
7275
7312
|
#browserCdpClient;
|
|
7313
|
+
#realmStorage;
|
|
7276
7314
|
#eventManager;
|
|
7277
7315
|
#preloadScriptStorage;
|
|
7278
7316
|
#browsingContextStorage;
|
|
7279
7317
|
#networkStorage;
|
|
7280
7318
|
#unblocked = new Deferred_js_1$1.Deferred();
|
|
7281
7319
|
#acceptInsecureCerts;
|
|
7320
|
+
#logger;
|
|
7282
7321
|
#networkDomainEnabled = false;
|
|
7283
7322
|
#fetchDomainStages = {
|
|
7284
7323
|
request: false,
|
|
@@ -7286,7 +7325,7 @@ var mapperTab = (function () {
|
|
|
7286
7325
|
auth: false,
|
|
7287
7326
|
};
|
|
7288
7327
|
static create(targetId, cdpClient, browserCdpClient, realmStorage, eventManager, preloadScriptStorage, browsingContextStorage, networkStorage, acceptInsecureCerts, logger) {
|
|
7289
|
-
const cdpTarget = new CdpTarget(targetId, cdpClient, browserCdpClient, eventManager, preloadScriptStorage, browsingContextStorage, networkStorage, acceptInsecureCerts);
|
|
7328
|
+
const cdpTarget = new CdpTarget(targetId, cdpClient, browserCdpClient, eventManager, realmStorage, preloadScriptStorage, browsingContextStorage, networkStorage, acceptInsecureCerts, logger);
|
|
7290
7329
|
LogManager_js_1.LogManager.create(cdpTarget, realmStorage, eventManager, logger);
|
|
7291
7330
|
cdpTarget.#setEventListeners();
|
|
7292
7331
|
// No need to await.
|
|
@@ -7294,15 +7333,17 @@ var mapperTab = (function () {
|
|
|
7294
7333
|
void cdpTarget.#unblock();
|
|
7295
7334
|
return cdpTarget;
|
|
7296
7335
|
}
|
|
7297
|
-
constructor(targetId, cdpClient, browserCdpClient, eventManager, preloadScriptStorage, browsingContextStorage, networkStorage, acceptInsecureCerts) {
|
|
7336
|
+
constructor(targetId, cdpClient, browserCdpClient, eventManager, realmStorage, preloadScriptStorage, browsingContextStorage, networkStorage, acceptInsecureCerts, logger) {
|
|
7298
7337
|
this.#id = targetId;
|
|
7299
7338
|
this.#cdpClient = cdpClient;
|
|
7300
7339
|
this.#browserCdpClient = browserCdpClient;
|
|
7301
7340
|
this.#eventManager = eventManager;
|
|
7341
|
+
this.#realmStorage = realmStorage;
|
|
7302
7342
|
this.#preloadScriptStorage = preloadScriptStorage;
|
|
7303
7343
|
this.#networkStorage = networkStorage;
|
|
7304
7344
|
this.#browsingContextStorage = browsingContextStorage;
|
|
7305
7345
|
this.#acceptInsecureCerts = acceptInsecureCerts;
|
|
7346
|
+
this.#logger = logger;
|
|
7306
7347
|
}
|
|
7307
7348
|
/** Returns a deferred that resolves when the target is unblocked. */
|
|
7308
7349
|
get unblocked() {
|
|
@@ -7328,8 +7369,19 @@ var mapperTab = (function () {
|
|
|
7328
7369
|
async #unblock() {
|
|
7329
7370
|
try {
|
|
7330
7371
|
await Promise.all([
|
|
7331
|
-
this.#cdpClient.sendCommand('Runtime.enable'),
|
|
7332
7372
|
this.#cdpClient.sendCommand('Page.enable'),
|
|
7373
|
+
// There can be some existing frames in the target, if reconnecting to an
|
|
7374
|
+
// existing browser instance, e.g. via Puppeteer. Need to restore the browsing
|
|
7375
|
+
// contexts for the frames to correctly handle further events, like
|
|
7376
|
+
// `Runtime.executionContextCreated`.
|
|
7377
|
+
// It's important to schedule this task together with enabling domains commands to
|
|
7378
|
+
// prepare the tree before the events (e.g. Runtime.executionContextCreated) start
|
|
7379
|
+
// coming.
|
|
7380
|
+
// https://github.com/GoogleChromeLabs/chromium-bidi/issues/2282
|
|
7381
|
+
this.#cdpClient
|
|
7382
|
+
.sendCommand('Page.getFrameTree')
|
|
7383
|
+
.then((frameTree) => this.#restoreFrameTreeState(frameTree.frameTree)),
|
|
7384
|
+
this.#cdpClient.sendCommand('Runtime.enable'),
|
|
7333
7385
|
this.#cdpClient.sendCommand('Page.setLifecycleEventsEnabled', {
|
|
7334
7386
|
enabled: true,
|
|
7335
7387
|
}),
|
|
@@ -7348,6 +7400,7 @@ var mapperTab = (function () {
|
|
|
7348
7400
|
]);
|
|
7349
7401
|
}
|
|
7350
7402
|
catch (error) {
|
|
7403
|
+
this.#logger?.(log_js_1$7.LogType.debugError, 'Failed to unblock target', error);
|
|
7351
7404
|
// The target might have been closed before the initialization finished.
|
|
7352
7405
|
if (!this.#cdpClient.isCloseError(error)) {
|
|
7353
7406
|
this.#unblocked.resolve({
|
|
@@ -7362,6 +7415,17 @@ var mapperTab = (function () {
|
|
|
7362
7415
|
value: undefined,
|
|
7363
7416
|
});
|
|
7364
7417
|
}
|
|
7418
|
+
#restoreFrameTreeState(frameTree) {
|
|
7419
|
+
const frame = frameTree.frame;
|
|
7420
|
+
if (this.#browsingContextStorage.findContext(frame.id) === undefined &&
|
|
7421
|
+
frame.parentId !== undefined) {
|
|
7422
|
+
// Can restore only not yet known nested frames. The top-level frame is created
|
|
7423
|
+
// when the target is attached.
|
|
7424
|
+
const parentBrowsingContext = this.#browsingContextStorage.getContext(frame.parentId);
|
|
7425
|
+
BrowsingContextImpl_js_1$1.BrowsingContextImpl.create(frame.id, frame.parentId, parentBrowsingContext.userContext, parentBrowsingContext.cdpTarget, this.#eventManager, this.#browsingContextStorage, this.#realmStorage, frame.url, this.#logger);
|
|
7426
|
+
}
|
|
7427
|
+
frameTree.childFrames?.map((frameTree) => this.#restoreFrameTreeState(frameTree));
|
|
7428
|
+
}
|
|
7365
7429
|
async toggleFetchIfNeeded() {
|
|
7366
7430
|
const stages = this.#networkStorage.getInterceptionStages(this.topLevelId);
|
|
7367
7431
|
if (
|
|
@@ -7520,7 +7584,10 @@ var mapperTab = (function () {
|
|
|
7520
7584
|
#handleFrameAttachedEvent(params) {
|
|
7521
7585
|
const parentBrowsingContext = this.#browsingContextStorage.findContext(params.parentFrameId);
|
|
7522
7586
|
if (parentBrowsingContext !== undefined) {
|
|
7523
|
-
BrowsingContextImpl_js_1.BrowsingContextImpl.create(params.frameId, params.parentFrameId, parentBrowsingContext.userContext, parentBrowsingContext.cdpTarget, this.#eventManager, this.#browsingContextStorage, this.#realmStorage,
|
|
7587
|
+
BrowsingContextImpl_js_1.BrowsingContextImpl.create(params.frameId, params.parentFrameId, parentBrowsingContext.userContext, parentBrowsingContext.cdpTarget, this.#eventManager, this.#browsingContextStorage, this.#realmStorage,
|
|
7588
|
+
// At this point, we don't know the URL of the frame yet, so it will be updated
|
|
7589
|
+
// later.
|
|
7590
|
+
'about:blank', this.#logger);
|
|
7524
7591
|
}
|
|
7525
7592
|
}
|
|
7526
7593
|
#handleFrameDetachedEvent(params) {
|
|
@@ -7551,7 +7618,16 @@ var mapperTab = (function () {
|
|
|
7551
7618
|
? targetInfo.browserContextId
|
|
7552
7619
|
: 'default';
|
|
7553
7620
|
// New context.
|
|
7554
|
-
BrowsingContextImpl_js_1.BrowsingContextImpl.create(targetInfo.targetId, null, userContext, cdpTarget, this.#eventManager, this.#browsingContextStorage, this.#realmStorage,
|
|
7621
|
+
BrowsingContextImpl_js_1.BrowsingContextImpl.create(targetInfo.targetId, null, userContext, cdpTarget, this.#eventManager, this.#browsingContextStorage, this.#realmStorage,
|
|
7622
|
+
// Hack: when a new target created, CDP emits targetInfoChanged with an empty
|
|
7623
|
+
// url, and navigates it to about:blank later. When the event is emitted for
|
|
7624
|
+
// an existing target (reconnect), the url is already known, and navigation
|
|
7625
|
+
// events will not be emitted anymore. Replacing empty url with `about:blank`
|
|
7626
|
+
// allows to handle both cases in the same way.
|
|
7627
|
+
// "7.3.2.1 Creating browsing contexts".
|
|
7628
|
+
// https://html.spec.whatwg.org/multipage/document-sequences.html#creating-browsing-contexts
|
|
7629
|
+
// TODO: check who to deal with non-null creator and its `creatorOrigin`.
|
|
7630
|
+
targetInfo.url === '' ? 'about:blank' : targetInfo.url, this.#logger);
|
|
7555
7631
|
}
|
|
7556
7632
|
return;
|
|
7557
7633
|
}
|
|
@@ -13737,10 +13813,15 @@ var mapperTab = (function () {
|
|
|
13737
13813
|
class ZodReadonly extends ZodType {
|
|
13738
13814
|
_parse(input) {
|
|
13739
13815
|
const result = this._def.innerType._parse(input);
|
|
13740
|
-
|
|
13741
|
-
|
|
13742
|
-
|
|
13743
|
-
|
|
13816
|
+
const freeze = (data) => {
|
|
13817
|
+
if ((0, parseUtil_1.isValid)(data)) {
|
|
13818
|
+
data.value = Object.freeze(data.value);
|
|
13819
|
+
}
|
|
13820
|
+
return data;
|
|
13821
|
+
};
|
|
13822
|
+
return (0, parseUtil_1.isAsync)(result)
|
|
13823
|
+
? result.then((data) => freeze(data))
|
|
13824
|
+
: freeze(result);
|
|
13744
13825
|
}
|
|
13745
13826
|
unwrap() {
|
|
13746
13827
|
return this._def.innerType;
|