capybara-simulated 0.1.1 → 0.3.0
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.
- checksums.yaml +4 -4
- data/README.md +91 -9
- data/lib/capybara/simulated/browser.rb +730 -73
- data/lib/capybara/simulated/driver.rb +92 -13
- data/lib/capybara/simulated/errors.rb +7 -0
- data/lib/capybara/simulated/js/bridge.bundle.js +608 -67
- data/lib/capybara/simulated/node.rb +19 -3
- data/lib/capybara/simulated/runtime_shared.rb +15 -0
- data/lib/capybara/simulated/v8_runtime.rb +64 -9
- data/lib/capybara/simulated/version.rb +1 -1
- metadata +1 -1
|
@@ -417,7 +417,7 @@
|
|
|
417
417
|
this._currentTarget = v;
|
|
418
418
|
}
|
|
419
419
|
});
|
|
420
|
-
var
|
|
420
|
+
var DOMException2 = class _DOMException extends Error {
|
|
421
421
|
static {
|
|
422
422
|
__name(this, "DOMException");
|
|
423
423
|
}
|
|
@@ -480,8 +480,8 @@
|
|
|
480
480
|
INVALID_NODE_TYPE_ERR: 24,
|
|
481
481
|
DATA_CLONE_ERR: 25
|
|
482
482
|
}).forEach(([k, v]) => {
|
|
483
|
-
Object.defineProperty(
|
|
484
|
-
Object.defineProperty(
|
|
483
|
+
Object.defineProperty(DOMException2, k, { value: v, enumerable: true });
|
|
484
|
+
Object.defineProperty(DOMException2.prototype, k, { value: v, enumerable: true });
|
|
485
485
|
});
|
|
486
486
|
var CustomEvent = class extends Event {
|
|
487
487
|
static {
|
|
@@ -3061,22 +3061,6 @@
|
|
|
3061
3061
|
else n._attrs.checked = "";
|
|
3062
3062
|
}
|
|
3063
3063
|
__name(toggleChecked, "toggleChecked");
|
|
3064
|
-
function formNamedAccess(form) {
|
|
3065
|
-
if (form._namedAccessProxy) return form._namedAccessProxy;
|
|
3066
|
-
const proxy = new Proxy(form, {
|
|
3067
|
-
get(target, key) {
|
|
3068
|
-
if (key in target) return target[key];
|
|
3069
|
-
if (typeof key !== "string") return target[key];
|
|
3070
|
-
for (const f of target.elements || []) {
|
|
3071
|
-
if (f._attrs && (f._attrs.name === key || f._attrs.id === key)) return f;
|
|
3072
|
-
}
|
|
3073
|
-
return void 0;
|
|
3074
|
-
}
|
|
3075
|
-
});
|
|
3076
|
-
form._namedAccessProxy = proxy;
|
|
3077
|
-
return proxy;
|
|
3078
|
-
}
|
|
3079
|
-
__name(formNamedAccess, "formNamedAccess");
|
|
3080
3064
|
function checkedRadioInGroup(n) {
|
|
3081
3065
|
const name = n._attrs.name;
|
|
3082
3066
|
if (!name) return n._attrs.checked != null ? n : null;
|
|
@@ -3290,7 +3274,7 @@
|
|
|
3290
3274
|
event.target = event._csimRetargets.has(node) ? event._csimRetargets.get(node) : event._csimTopRetarget;
|
|
3291
3275
|
}
|
|
3292
3276
|
if (!capture && node._attrs && !event._immediatePropagationStopped) {
|
|
3293
|
-
const attrName = "on" + event.type;
|
|
3277
|
+
const attrName = "on" + event.type.toLowerCase();
|
|
3294
3278
|
const propHandler = typeof node[attrName] === "function" ? node[attrName] : null;
|
|
3295
3279
|
const attrVal = propHandler ? null : node._attrs[attrName];
|
|
3296
3280
|
let handler = propHandler;
|
|
@@ -3535,6 +3519,18 @@
|
|
|
3535
3519
|
});
|
|
3536
3520
|
}
|
|
3537
3521
|
__name(fireCEDisconnect, "fireCEDisconnect");
|
|
3522
|
+
function fireCEMoveReactions(subtree) {
|
|
3523
|
+
walk(subtree, (el) => {
|
|
3524
|
+
if (!registry.has(el._tag)) return;
|
|
3525
|
+
if (typeof el.connectedMoveCallback === "function") {
|
|
3526
|
+
fireCEHook(el, "connectedMoveCallback");
|
|
3527
|
+
} else {
|
|
3528
|
+
fireCEHook(el, "disconnectedCallback");
|
|
3529
|
+
fireCEHook(el, "connectedCallback");
|
|
3530
|
+
}
|
|
3531
|
+
});
|
|
3532
|
+
}
|
|
3533
|
+
__name(fireCEMoveReactions, "fireCEMoveReactions");
|
|
3538
3534
|
globalThis.customElements = customElements;
|
|
3539
3535
|
|
|
3540
3536
|
// lib/capybara/simulated/js/src/html-parser.js
|
|
@@ -3681,7 +3677,7 @@
|
|
|
3681
3677
|
]);
|
|
3682
3678
|
var P_SCOPE_BOUNDARY = /* @__PURE__ */ new Set(["applet", "caption", "html", "table", "td", "th", "marquee", "object", "template", "button"]);
|
|
3683
3679
|
var DOCTYPE_RE = /^\s*<!doctype\s+([^\s>]+)(?:\s+(?:public\s+("[^"]*"|'[^']*')(?:\s+("[^"]*"|'[^']*'))?|system\s+("[^"]*"|'[^']*')))?[^>]*>/i;
|
|
3684
|
-
function installHtmlParser({ Document: Document2, Element: Element2, Text: Text2, Comment: Comment2, DocumentFragment: DocumentFragment2, DocumentType: DocumentType2, createHtmlPageDocument: createHtmlPageDocument2 }) {
|
|
3680
|
+
function installHtmlParser({ Document: Document2, Element: Element2, Text: Text2, Comment: Comment2, DocumentFragment: DocumentFragment2, DocumentType: DocumentType2, createHtmlPageDocument: createHtmlPageDocument2, registerNamedAccess: registerNamedAccess2 }) {
|
|
3685
3681
|
const unquote = /* @__PURE__ */ __name((s) => s == null ? "" : s.slice(1, -1), "unquote");
|
|
3686
3682
|
const HTML_NS_P = "http://www.w3.org/1999/xhtml";
|
|
3687
3683
|
const SVG_NS_P = "http://www.w3.org/2000/svg";
|
|
@@ -3975,7 +3971,10 @@
|
|
|
3975
3971
|
if (fa) (el._attrNS || (el._attrNS = {}))[fa.key] = fa.meta;
|
|
3976
3972
|
continue;
|
|
3977
3973
|
}
|
|
3978
|
-
|
|
3974
|
+
const k = asciiLowerAttr(m[1]);
|
|
3975
|
+
const dv = decodeEntities(v);
|
|
3976
|
+
el._attrs[k] = dv;
|
|
3977
|
+
if (k === "id" || k === "name") registerNamedAccess2(el, k, dv);
|
|
3979
3978
|
}
|
|
3980
3979
|
}
|
|
3981
3980
|
__name(applyAttributes, "applyAttributes");
|
|
@@ -4533,6 +4532,18 @@
|
|
|
4533
4532
|
return globalThis.__csim_transferStash(view) | 0;
|
|
4534
4533
|
}
|
|
4535
4534
|
__name(stashTransfer, "stashTransfer");
|
|
4535
|
+
function detachTransferables(transferList) {
|
|
4536
|
+
if (!Array.isArray(transferList)) return;
|
|
4537
|
+
for (const t of transferList) {
|
|
4538
|
+
if (t instanceof ArrayBuffer && typeof t.transfer === "function") {
|
|
4539
|
+
try {
|
|
4540
|
+
t.transfer();
|
|
4541
|
+
} catch (_) {
|
|
4542
|
+
}
|
|
4543
|
+
}
|
|
4544
|
+
}
|
|
4545
|
+
}
|
|
4546
|
+
__name(detachTransferables, "detachTransferables");
|
|
4536
4547
|
|
|
4537
4548
|
// lib/capybara/simulated/js/src/workers.js
|
|
4538
4549
|
function hasWorkers() {
|
|
@@ -4541,28 +4552,51 @@
|
|
|
4541
4552
|
}
|
|
4542
4553
|
__name(hasWorkers, "hasWorkers");
|
|
4543
4554
|
var TRANSFER_STASH_MIN = 64 * 1024;
|
|
4544
|
-
function
|
|
4555
|
+
function transferSetFrom(transferList) {
|
|
4556
|
+
if (!transferList || !transferList.length) return null;
|
|
4557
|
+
const set = /* @__PURE__ */ new Set();
|
|
4558
|
+
for (const t of transferList) set.add(t instanceof ArrayBuffer ? t : t && t.buffer || t);
|
|
4559
|
+
return set;
|
|
4560
|
+
}
|
|
4561
|
+
__name(transferSetFrom, "transferSetFrom");
|
|
4562
|
+
function encode(data, transferSet) {
|
|
4563
|
+
const NS = globalThis.RustyRacer;
|
|
4564
|
+
const canTransfer = transferSet && NS && typeof NS.transferOut === "function";
|
|
4545
4565
|
return JSON.stringify(data, function(_key, value) {
|
|
4546
4566
|
const isU8 = value instanceof Uint8Array;
|
|
4547
4567
|
const isAB = !isU8 && value instanceof ArrayBuffer;
|
|
4548
4568
|
if (!isU8 && !isAB) return value;
|
|
4569
|
+
const type = isU8 ? "Uint8Array" : "ArrayBuffer";
|
|
4570
|
+
const buf = isU8 ? value.buffer : value;
|
|
4571
|
+
if (canTransfer && transferSet.has(buf)) {
|
|
4572
|
+
const token = NS.transferOut(value) | 0;
|
|
4573
|
+
if (token > 0) {
|
|
4574
|
+
if (globalThis.__csim_transferIssued) globalThis.__csim_transferIssued(token);
|
|
4575
|
+
return isU8 ? { __csimType: type, xfer: token, byteOffset: value.byteOffset, length: value.length } : { __csimType: type, xfer: token };
|
|
4576
|
+
}
|
|
4577
|
+
}
|
|
4549
4578
|
const view = isU8 ? value : new Uint8Array(value);
|
|
4550
4579
|
if (view.byteLength >= TRANSFER_STASH_MIN) {
|
|
4551
4580
|
const refId = stashTransfer(view);
|
|
4552
|
-
if (refId > 0) return { __csimType:
|
|
4581
|
+
if (refId > 0) return { __csimType: type, refId };
|
|
4553
4582
|
}
|
|
4554
|
-
return {
|
|
4555
|
-
__csimType: isU8 ? "Uint8Array" : "ArrayBuffer",
|
|
4556
|
-
b64: globalThis.btoa(bytesToLatin1(view))
|
|
4557
|
-
};
|
|
4583
|
+
return { __csimType: type, b64: globalThis.btoa(bytesToLatin1(view)) };
|
|
4558
4584
|
});
|
|
4559
4585
|
}
|
|
4560
4586
|
__name(encode, "encode");
|
|
4561
4587
|
function decode(s) {
|
|
4588
|
+
const NS = globalThis.RustyRacer;
|
|
4562
4589
|
return JSON.parse(s, function(_key, value) {
|
|
4563
4590
|
if (!value || typeof value !== "object") return value;
|
|
4564
4591
|
const tag = value.__csimType;
|
|
4565
4592
|
if (tag !== "Uint8Array" && tag !== "ArrayBuffer") return value;
|
|
4593
|
+
if (value.xfer != null && NS && typeof NS.transferIn === "function") {
|
|
4594
|
+
const ab = NS.transferIn(value.xfer);
|
|
4595
|
+
if (ab) {
|
|
4596
|
+
return tag === "ArrayBuffer" ? ab : new Uint8Array(ab, value.byteOffset || 0, value.length != null ? value.length : ab.byteLength);
|
|
4597
|
+
}
|
|
4598
|
+
return tag === "ArrayBuffer" ? new ArrayBuffer(0) : new Uint8Array(0);
|
|
4599
|
+
}
|
|
4566
4600
|
const u = fetchTransfer(value.refId) || latin1ToBytes(globalThis.atob(value.b64 || ""));
|
|
4567
4601
|
return tag === "ArrayBuffer" ? u.buffer : u;
|
|
4568
4602
|
});
|
|
@@ -4586,15 +4620,16 @@
|
|
|
4586
4620
|
this._handle = globalThis.__csim_workerSpawn(this.url) | 0;
|
|
4587
4621
|
if (this._handle > 0) byHandle.set(this._handle, this);
|
|
4588
4622
|
}
|
|
4589
|
-
postMessage(data,
|
|
4623
|
+
postMessage(data, transferList) {
|
|
4590
4624
|
if (this._handle <= 0) return;
|
|
4591
4625
|
let payload;
|
|
4592
4626
|
try {
|
|
4593
|
-
payload = encode(data);
|
|
4627
|
+
payload = encode(data, transferSetFrom(transferList));
|
|
4594
4628
|
} catch (_) {
|
|
4595
4629
|
payload = "null";
|
|
4596
4630
|
}
|
|
4597
4631
|
globalThis.__csim_workerPostToWorker(this._handle, payload);
|
|
4632
|
+
detachTransferables(transferList);
|
|
4598
4633
|
}
|
|
4599
4634
|
terminate() {
|
|
4600
4635
|
if (this._handle <= 0) return;
|
|
@@ -4644,19 +4679,30 @@
|
|
|
4644
4679
|
} catch (_) {
|
|
4645
4680
|
globalThis.document = void 0;
|
|
4646
4681
|
}
|
|
4682
|
+
try {
|
|
4683
|
+
delete globalThis.open;
|
|
4684
|
+
} catch (_) {
|
|
4685
|
+
globalThis.open = void 0;
|
|
4686
|
+
}
|
|
4687
|
+
try {
|
|
4688
|
+
delete globalThis.opener;
|
|
4689
|
+
} catch (_) {
|
|
4690
|
+
globalThis.opener = void 0;
|
|
4691
|
+
}
|
|
4647
4692
|
globalThis.WorkerGlobalScope = globalThis.WorkerGlobalScope || /* @__PURE__ */ __name(function WorkerGlobalScope() {
|
|
4648
4693
|
}, "WorkerGlobalScope");
|
|
4649
4694
|
globalThis.DedicatedWorkerGlobalScope = globalThis.DedicatedWorkerGlobalScope || /* @__PURE__ */ __name(function DedicatedWorkerGlobalScope() {
|
|
4650
4695
|
}, "DedicatedWorkerGlobalScope");
|
|
4651
4696
|
if (typeof globalThis.postMessage !== "function") {
|
|
4652
|
-
globalThis.postMessage = function(data,
|
|
4697
|
+
globalThis.postMessage = function(data, transferList) {
|
|
4653
4698
|
let payload;
|
|
4654
4699
|
try {
|
|
4655
|
-
payload = encode(data);
|
|
4700
|
+
payload = encode(data, transferSetFrom(transferList));
|
|
4656
4701
|
} catch (_) {
|
|
4657
4702
|
payload = "null";
|
|
4658
4703
|
}
|
|
4659
4704
|
globalThis.__csim_workerPostMessage(payload);
|
|
4705
|
+
detachTransferables(transferList);
|
|
4660
4706
|
};
|
|
4661
4707
|
}
|
|
4662
4708
|
globalThis.importScripts = function(...urls) {
|
|
@@ -6266,7 +6312,13 @@
|
|
|
6266
6312
|
// lib/capybara/simulated/js/src/xml-parser.js
|
|
6267
6313
|
var XML_NS = "http://www.w3.org/XML/1998/namespace";
|
|
6268
6314
|
var XMLNS_NS = "http://www.w3.org/2000/xmlns/";
|
|
6315
|
+
var PARSERERROR_NS = "http://www.mozilla.org/newlayout/xml/parsererror.xml";
|
|
6269
6316
|
var isWs = /* @__PURE__ */ __name((c) => c === " " || c === " " || c === "\n" || c === "\r" || c === "\f", "isWs");
|
|
6317
|
+
var isNCName = /* @__PURE__ */ __name((s) => /^[A-Za-z_][\w.\-]*$/.test(s), "isNCName");
|
|
6318
|
+
var isQName = /* @__PURE__ */ __name((s) => {
|
|
6319
|
+
const c = s.indexOf(":");
|
|
6320
|
+
return c === -1 ? isNCName(s) : isNCName(s.slice(0, c)) && isNCName(s.slice(c + 1));
|
|
6321
|
+
}, "isQName");
|
|
6270
6322
|
function findTagEnd(s, lt) {
|
|
6271
6323
|
let q = null;
|
|
6272
6324
|
for (let i = lt + 1; i < s.length; i++) {
|
|
@@ -6282,6 +6334,7 @@
|
|
|
6282
6334
|
function parseTag(inner) {
|
|
6283
6335
|
let i = 0;
|
|
6284
6336
|
const n = inner.length;
|
|
6337
|
+
let err = false;
|
|
6285
6338
|
while (i < n && isWs(inner[i])) i++;
|
|
6286
6339
|
let nameEnd = i;
|
|
6287
6340
|
while (nameEnd < n && !isWs(inner[nameEnd])) nameEnd++;
|
|
@@ -6291,30 +6344,35 @@
|
|
|
6291
6344
|
while (i < n) {
|
|
6292
6345
|
while (i < n && (isWs(inner[i]) || inner[i] === "/")) i++;
|
|
6293
6346
|
if (i >= n) break;
|
|
6347
|
+
if (inner[i] === "=") {
|
|
6348
|
+
err = true;
|
|
6349
|
+
break;
|
|
6350
|
+
}
|
|
6294
6351
|
let ae = i;
|
|
6295
6352
|
while (ae < n && !isWs(inner[ae]) && inner[ae] !== "=") ae++;
|
|
6296
6353
|
const aname = inner.slice(i, ae);
|
|
6297
6354
|
i = ae;
|
|
6298
6355
|
while (i < n && isWs(inner[i])) i++;
|
|
6299
|
-
|
|
6300
|
-
|
|
6301
|
-
|
|
6302
|
-
while (i < n && isWs(inner[i])) i++;
|
|
6303
|
-
const q = inner[i];
|
|
6304
|
-
if (q === '"' || q === "'") {
|
|
6305
|
-
const end = inner.indexOf(q, i + 1);
|
|
6306
|
-
avalue = end === -1 ? inner.slice(i + 1) : inner.slice(i + 1, end);
|
|
6307
|
-
i = end === -1 ? n : end + 1;
|
|
6308
|
-
} else {
|
|
6309
|
-
let ve = i;
|
|
6310
|
-
while (ve < n && !isWs(inner[ve])) ve++;
|
|
6311
|
-
avalue = inner.slice(i, ve);
|
|
6312
|
-
i = ve;
|
|
6313
|
-
}
|
|
6356
|
+
if (inner[i] !== "=") {
|
|
6357
|
+
err = true;
|
|
6358
|
+
break;
|
|
6314
6359
|
}
|
|
6315
|
-
|
|
6360
|
+
i++;
|
|
6361
|
+
while (i < n && isWs(inner[i])) i++;
|
|
6362
|
+
const q = inner[i];
|
|
6363
|
+
if (q !== '"' && q !== "'") {
|
|
6364
|
+
err = true;
|
|
6365
|
+
break;
|
|
6366
|
+
}
|
|
6367
|
+
const end = inner.indexOf(q, i + 1);
|
|
6368
|
+
if (end === -1) {
|
|
6369
|
+
err = true;
|
|
6370
|
+
break;
|
|
6371
|
+
}
|
|
6372
|
+
attrs.push({ name: aname, value: decodeEntities(inner.slice(i + 1, end)) });
|
|
6373
|
+
i = end + 1;
|
|
6316
6374
|
}
|
|
6317
|
-
return { name, attrs };
|
|
6375
|
+
return { name, attrs, err };
|
|
6318
6376
|
}
|
|
6319
6377
|
__name(parseTag, "parseTag");
|
|
6320
6378
|
function installXmlParser({ Element: Element2, Text: Text2, Comment: Comment2, ProcessingInstruction: ProcessingInstruction2, CDATASection: CDATASection2, DocumentType: DocumentType2 }) {
|
|
@@ -6341,6 +6399,7 @@
|
|
|
6341
6399
|
const stack = [];
|
|
6342
6400
|
const nsStack = [{ xml: XML_NS }];
|
|
6343
6401
|
let i = 0;
|
|
6402
|
+
let err = false;
|
|
6344
6403
|
const append = /* @__PURE__ */ __name((node) => {
|
|
6345
6404
|
if (stack.length) {
|
|
6346
6405
|
node._parent = stack[stack.length - 1];
|
|
@@ -6380,30 +6439,58 @@
|
|
|
6380
6439
|
}
|
|
6381
6440
|
} else if (s[i + 1] === "/") {
|
|
6382
6441
|
const end = s.indexOf(">", i);
|
|
6383
|
-
|
|
6442
|
+
const raw = end === -1 ? s.slice(i + 2) : s.slice(i + 2, end);
|
|
6443
|
+
const endName = raw.replace(/\s+$/, "");
|
|
6444
|
+
if (end === -1 || /^\s/.test(raw) || !endName) err = true;
|
|
6445
|
+
if (stack.length === 0) {
|
|
6446
|
+
err = true;
|
|
6447
|
+
} else {
|
|
6448
|
+
const top2 = stack[stack.length - 1];
|
|
6449
|
+
const openName = top2._prefix ? top2._prefix + ":" + top2._localName : top2._localName;
|
|
6450
|
+
if (endName !== openName) err = true;
|
|
6384
6451
|
stack.pop();
|
|
6385
6452
|
nsStack.pop();
|
|
6386
6453
|
}
|
|
6387
6454
|
i = end === -1 ? n : end + 1;
|
|
6388
6455
|
} else {
|
|
6456
|
+
if (isWs(s[i + 1])) err = true;
|
|
6389
6457
|
const end = findTagEnd(s, i);
|
|
6390
6458
|
if (end === -1) {
|
|
6459
|
+
err = true;
|
|
6391
6460
|
i = n;
|
|
6392
6461
|
break;
|
|
6393
6462
|
}
|
|
6394
6463
|
let inner = s.slice(i + 1, end);
|
|
6395
6464
|
const selfClose = /\/\s*$/.test(inner);
|
|
6396
6465
|
if (selfClose) inner = inner.replace(/\/\s*$/, "");
|
|
6397
|
-
const { name, attrs } = parseTag(inner);
|
|
6466
|
+
const { name, attrs, err: tagErr } = parseTag(inner);
|
|
6467
|
+
if (tagErr || !isQName(name)) err = true;
|
|
6398
6468
|
i = end + 1;
|
|
6399
6469
|
const scope = Object.assign({}, nsStack[nsStack.length - 1]);
|
|
6400
6470
|
for (const a of attrs) {
|
|
6401
|
-
if (a.name === "xmlns")
|
|
6402
|
-
|
|
6471
|
+
if (a.name === "xmlns") {
|
|
6472
|
+
scope[""] = a.value || null;
|
|
6473
|
+
} else if (a.name.slice(0, 6) === "xmlns:") {
|
|
6474
|
+
const p = a.name.slice(6);
|
|
6475
|
+
if (!isNCName(p) || p === "xmlns") err = true;
|
|
6476
|
+
else scope[p] = a.value || null;
|
|
6477
|
+
}
|
|
6478
|
+
}
|
|
6479
|
+
for (const a of attrs) {
|
|
6480
|
+
if (a.name === "xmlns" || a.name.slice(0, 6) === "xmlns:") continue;
|
|
6481
|
+
if (!isQName(a.name)) {
|
|
6482
|
+
err = true;
|
|
6483
|
+
continue;
|
|
6484
|
+
}
|
|
6485
|
+
const ac = a.name.indexOf(":");
|
|
6486
|
+
if (ac !== -1 && a.name.slice(0, ac) !== "xml" && !(a.name.slice(0, ac) in scope)) {
|
|
6487
|
+
err = true;
|
|
6488
|
+
}
|
|
6403
6489
|
}
|
|
6404
6490
|
const colon = name.indexOf(":");
|
|
6405
6491
|
const prefix = colon === -1 ? null : name.slice(0, colon);
|
|
6406
6492
|
const localName = colon === -1 ? name : name.slice(colon + 1);
|
|
6493
|
+
if (prefix && prefix !== "xml" && !(prefix in scope)) err = true;
|
|
6407
6494
|
const ns = prefix ? scope[prefix] || null : scope[""] || null;
|
|
6408
6495
|
const el = new Element2(name);
|
|
6409
6496
|
el._localName = localName;
|
|
@@ -6437,6 +6524,16 @@
|
|
|
6437
6524
|
i = j;
|
|
6438
6525
|
}
|
|
6439
6526
|
}
|
|
6527
|
+
if (stack.length > 0) err = true;
|
|
6528
|
+
if (err) {
|
|
6529
|
+
const pe = new Element2("parsererror");
|
|
6530
|
+
pe._localName = "parsererror";
|
|
6531
|
+
pe._ns = PARSERERROR_NS;
|
|
6532
|
+
const msg = new Text2("XML parsing error");
|
|
6533
|
+
msg._parent = pe;
|
|
6534
|
+
pe._children.push(msg);
|
|
6535
|
+
return [pe];
|
|
6536
|
+
}
|
|
6440
6537
|
return top;
|
|
6441
6538
|
}
|
|
6442
6539
|
__name(parseXml2, "parseXml");
|
|
@@ -7855,6 +7952,7 @@
|
|
|
7855
7952
|
registerSubtree(c);
|
|
7856
7953
|
}
|
|
7857
7954
|
recordChildList(this, moved.slice(), [], prevSib, nextSib);
|
|
7955
|
+
if (this._tag === "script") globalThis.__csimScriptChildrenChanged(this);
|
|
7858
7956
|
if (connected) for (const c of moved) globalThis.__csimFireCEConnect(c);
|
|
7859
7957
|
for (const c of moved) askForReset(c);
|
|
7860
7958
|
return frag;
|
|
@@ -7898,6 +7996,7 @@
|
|
|
7898
7996
|
liveRangesOnInsert(this, insertIndex, 1);
|
|
7899
7997
|
registerSubtree(child);
|
|
7900
7998
|
recordChildList(this, [child], []);
|
|
7999
|
+
if (this._tag === "script") globalThis.__csimScriptChildrenChanged(this);
|
|
7901
8000
|
if (isConnected(this)) globalThis.__csimFireCEConnect(child);
|
|
7902
8001
|
askForReset(child);
|
|
7903
8002
|
return child;
|
|
@@ -7920,6 +8019,9 @@
|
|
|
7920
8019
|
this._children.splice(i, 1);
|
|
7921
8020
|
child._parent = null;
|
|
7922
8021
|
unregisterSubtree(child);
|
|
8022
|
+
const doc = globalThis.document;
|
|
8023
|
+
const ae = doc && doc._activeElement;
|
|
8024
|
+
if (ae && (ae === child || nodeContains(child, ae))) doc._activeElement = null;
|
|
7923
8025
|
recordChildList(this, [], [child], prevSib, nextSib);
|
|
7924
8026
|
if (wasConnected) fireCEDisconnect(child);
|
|
7925
8027
|
return child;
|
|
@@ -7942,6 +8044,7 @@
|
|
|
7942
8044
|
liveRangesOnInsert(this, i, 1);
|
|
7943
8045
|
registerSubtree(child);
|
|
7944
8046
|
recordChildList(this, [child], []);
|
|
8047
|
+
if (this._tag === "script") globalThis.__csimScriptChildrenChanged(this);
|
|
7945
8048
|
if (isConnected(this)) globalThis.__csimFireCEConnect(child);
|
|
7946
8049
|
askForReset(child);
|
|
7947
8050
|
return child;
|
|
@@ -8485,6 +8588,7 @@
|
|
|
8485
8588
|
this._vtGen = -1;
|
|
8486
8589
|
this._vtCV = -1;
|
|
8487
8590
|
this._attrsColl = null;
|
|
8591
|
+
if (this._tag === "form") Object.setPrototypeOf(this, FormNamedProto);
|
|
8488
8592
|
}
|
|
8489
8593
|
_cloneShell() {
|
|
8490
8594
|
const e = new _Element(this._tag);
|
|
@@ -8542,6 +8646,61 @@
|
|
|
8542
8646
|
}
|
|
8543
8647
|
Object.defineProperty(this, "content", { value: v, writable: true, configurable: true, enumerable: true });
|
|
8544
8648
|
}
|
|
8649
|
+
// `HTMLStyleElement.sheet` — the CSSStyleSheet associated with a connected
|
|
8650
|
+
// `<style>` (CSSOM). It exists once the element is in a document and reflects
|
|
8651
|
+
// the element's current text content, so an earlier-inserted script can
|
|
8652
|
+
// observe a later-inserted `<style>` already applied (cssRules track the text
|
|
8653
|
+
// live). Disconnected → null; `<link>` sheets (which need the fetched
|
|
8654
|
+
// resource) are not modelled here. Created lazily and cached for stable identity.
|
|
8655
|
+
get sheet() {
|
|
8656
|
+
if (this._tag === "style") {
|
|
8657
|
+
if (!this.isConnected) {
|
|
8658
|
+
this._sheet = null;
|
|
8659
|
+
return null;
|
|
8660
|
+
}
|
|
8661
|
+
const type = (this._attrs.type || "").toLowerCase();
|
|
8662
|
+
if (type && type !== "text/css") {
|
|
8663
|
+
this._sheet = null;
|
|
8664
|
+
return null;
|
|
8665
|
+
}
|
|
8666
|
+
if (!this._sheet) {
|
|
8667
|
+
this._sheet = new globalThis.CSSStyleSheet();
|
|
8668
|
+
this._sheet.ownerNode = this;
|
|
8669
|
+
}
|
|
8670
|
+
this._sheet.replaceSync(this.textContent || "");
|
|
8671
|
+
return this._sheet;
|
|
8672
|
+
}
|
|
8673
|
+
if (this._tag === "link") {
|
|
8674
|
+
const rel = (this._attrs.rel || "").toLowerCase().split(/\s+/);
|
|
8675
|
+
const href = this._attrs.href;
|
|
8676
|
+
if (!this.isConnected || !rel.includes("stylesheet") || !href) {
|
|
8677
|
+
this._sheet = null;
|
|
8678
|
+
return null;
|
|
8679
|
+
}
|
|
8680
|
+
if (!this._sheet) {
|
|
8681
|
+
this._sheet = new globalThis.CSSStyleSheet();
|
|
8682
|
+
this._sheet.ownerNode = this;
|
|
8683
|
+
this._sheet.href = href;
|
|
8684
|
+
let css = "";
|
|
8685
|
+
const dataCss = /^data:text\/css[^,]*,(.*)$/is.exec(href);
|
|
8686
|
+
if (dataCss) {
|
|
8687
|
+
try {
|
|
8688
|
+
css = decodeURIComponent(dataCss[1]);
|
|
8689
|
+
} catch (_) {
|
|
8690
|
+
css = dataCss[1];
|
|
8691
|
+
}
|
|
8692
|
+
} else {
|
|
8693
|
+
try {
|
|
8694
|
+
css = globalThis.__csimExternalAsset(href) || "";
|
|
8695
|
+
} catch (_) {
|
|
8696
|
+
}
|
|
8697
|
+
}
|
|
8698
|
+
this._sheet.replaceSync(css);
|
|
8699
|
+
}
|
|
8700
|
+
return this._sheet;
|
|
8701
|
+
}
|
|
8702
|
+
return void 0;
|
|
8703
|
+
}
|
|
8545
8704
|
// `<dialog>` HTML interface — show() / showModal() / close() per
|
|
8546
8705
|
// HTMLDialogElement. Turbo's confirm flow uses this: opens
|
|
8547
8706
|
// `<dialog id="turbo-confirm">` via `showModal()`, waits for the
|
|
@@ -8610,6 +8769,7 @@
|
|
|
8610
8769
|
const old = this._attrs[n];
|
|
8611
8770
|
const next = String(value);
|
|
8612
8771
|
this._attrs[n] = next;
|
|
8772
|
+
if ((n === "id" || n === "name") && next) registerNamedAccess(this, n, next);
|
|
8613
8773
|
if ((n === "src" || n === "srcdoc") && (this._tag === "iframe" || this._tag === "frame") && old !== next) {
|
|
8614
8774
|
const oldRealmId = this._frameRealmId;
|
|
8615
8775
|
this._frameWindow = null;
|
|
@@ -8642,6 +8802,7 @@
|
|
|
8642
8802
|
const old = this._attrs[key];
|
|
8643
8803
|
const next = String(value);
|
|
8644
8804
|
this._attrs[key] = next;
|
|
8805
|
+
if (rns === null && (localName === "id" || localName === "name") && next) registerNamedAccess(this, localName, next);
|
|
8645
8806
|
if (rns !== null || prefix !== null || key !== qn) {
|
|
8646
8807
|
(this._attrNS || (this._attrNS = {}))[key] = { ns: rns, prefix, localName };
|
|
8647
8808
|
} else if (this._attrNS) {
|
|
@@ -8711,6 +8872,7 @@
|
|
|
8711
8872
|
_setAttrNodeValue(key, value) {
|
|
8712
8873
|
const old = this._attrs[key];
|
|
8713
8874
|
this._attrs[key] = value;
|
|
8875
|
+
if ((key === "id" || key === "name") && value) registerNamedAccess(this, key, value);
|
|
8714
8876
|
recordAttrMutation(this, key, old == null ? null : old);
|
|
8715
8877
|
if (old !== value) fireAttrChangedCallback(this, key, old == null ? null : old, value, _Element);
|
|
8716
8878
|
}
|
|
@@ -8732,6 +8894,7 @@
|
|
|
8732
8894
|
const key = hasNs ? this._attrKeyByNS(attr._ns, attr._localName) || freshAttrKey(this, qn) : asciiLower2(qn);
|
|
8733
8895
|
const old = this._attrs[key];
|
|
8734
8896
|
this._attrs[key] = attr._value;
|
|
8897
|
+
if (!hasNs && (key === "id" || key === "name") && attr._value) registerNamedAccess(this, key, attr._value);
|
|
8735
8898
|
if (hasNs) (this._attrNS || (this._attrNS = {}))[key] = { ns: attr._ns, prefix: attr._prefix, localName: attr._localName };
|
|
8736
8899
|
else if (this._attrNS) delete this._attrNS[key];
|
|
8737
8900
|
attr._ownerElement = this;
|
|
@@ -9121,8 +9284,7 @@
|
|
|
9121
9284
|
// `this.form` the onclick threw and the columns never moved.
|
|
9122
9285
|
get form() {
|
|
9123
9286
|
if (!FORM_ASSOCIATED_TAGS.has(this._tag)) return void 0;
|
|
9124
|
-
|
|
9125
|
-
return form ? formNamedAccess(form) : null;
|
|
9287
|
+
return formForControl(this) || null;
|
|
9126
9288
|
}
|
|
9127
9289
|
// Form-control IDL attributes — expose the pair-of-attr-and-IDL
|
|
9128
9290
|
// shape so JS like `input.value = 'x'` / `input.checked = true`
|
|
@@ -10671,6 +10833,93 @@
|
|
|
10671
10833
|
return globalThis.customElements || null;
|
|
10672
10834
|
}
|
|
10673
10835
|
});
|
|
10836
|
+
var FormNamedProto = Object.create(Element.prototype);
|
|
10837
|
+
var FORM_NAMED_PROPS = /* @__PURE__ */ new Set();
|
|
10838
|
+
var FORM_NAMED_TAGS = /* @__PURE__ */ new Set(["input", "select", "textarea", "button", "fieldset", "object"]);
|
|
10839
|
+
function formNamedLookup(form, name) {
|
|
10840
|
+
if (!form || form._tag !== "form") return void 0;
|
|
10841
|
+
const els = form.elements;
|
|
10842
|
+
if (els) for (const c of els) {
|
|
10843
|
+
if (c._attrs && (c._attrs.name === name || c._attrs.id === name)) return c;
|
|
10844
|
+
}
|
|
10845
|
+
return void 0;
|
|
10846
|
+
}
|
|
10847
|
+
__name(formNamedLookup, "formNamedLookup");
|
|
10848
|
+
function registerFormName(el, value) {
|
|
10849
|
+
if (!value || !FORM_NAMED_TAGS.has(el._tag)) return;
|
|
10850
|
+
if (FORM_NAMED_PROPS.has(value)) return;
|
|
10851
|
+
FORM_NAMED_PROPS.add(value);
|
|
10852
|
+
if (value in FormNamedProto) return;
|
|
10853
|
+
Object.defineProperty(FormNamedProto, value, {
|
|
10854
|
+
configurable: true,
|
|
10855
|
+
enumerable: false,
|
|
10856
|
+
get() {
|
|
10857
|
+
return formNamedLookup(this, value);
|
|
10858
|
+
},
|
|
10859
|
+
// Assigning `form.<name> = x` creates an OWN property that shadows the
|
|
10860
|
+
// named getter — matching browser LegacyPlatformObject semantics (named
|
|
10861
|
+
// properties are configurable). Without a setter, strict-mode assignment
|
|
10862
|
+
// to a getter-only property THROWS; jQuery stores its private-data expando
|
|
10863
|
+
// directly on the element (`form[expando] = cache`) and also parks its
|
|
10864
|
+
// marker on `id`/`name` during scoped queries, so a getter-only named prop
|
|
10865
|
+
// would break every form jQuery binds an event to or calls `.data()` on.
|
|
10866
|
+
set(v) {
|
|
10867
|
+
Object.defineProperty(this, value, { value: v, writable: true, enumerable: true, configurable: true });
|
|
10868
|
+
}
|
|
10869
|
+
});
|
|
10870
|
+
}
|
|
10871
|
+
__name(registerFormName, "registerFormName");
|
|
10872
|
+
var WINDOW_NAMED_PROPS = /* @__PURE__ */ new Set();
|
|
10873
|
+
var WINDOW_NAME_VALUES = /* @__PURE__ */ new Set();
|
|
10874
|
+
var WINDOW_NAME_TAGS = /* @__PURE__ */ new Set(["a", "applet", "area", "embed", "form", "frameset", "frame", "iframe", "img", "object"]);
|
|
10875
|
+
var WindowNamedProps = Object.create(Object.getPrototypeOf(globalThis));
|
|
10876
|
+
if (!globalThis.__csimWindowNamedProps) {
|
|
10877
|
+
globalThis.__csimWindowNamedProps = WindowNamedProps;
|
|
10878
|
+
Object.setPrototypeOf(globalThis, WindowNamedProps);
|
|
10879
|
+
}
|
|
10880
|
+
function windowNamedLookup(name) {
|
|
10881
|
+
const doc = globalThis.document;
|
|
10882
|
+
if (!doc) return void 0;
|
|
10883
|
+
const byId3 = doc.getElementById && doc.getElementById(name);
|
|
10884
|
+
if (byId3) return byId3;
|
|
10885
|
+
if (!WINDOW_NAME_VALUES.has(name)) return void 0;
|
|
10886
|
+
let found;
|
|
10887
|
+
walkSubtree(doc, (el) => {
|
|
10888
|
+
if (found || el.nodeType !== NODE_ELEMENT) return;
|
|
10889
|
+
if (WINDOW_NAME_TAGS.has(el._tag) && el._attrs && el._attrs.name === name) found = el;
|
|
10890
|
+
});
|
|
10891
|
+
return found;
|
|
10892
|
+
}
|
|
10893
|
+
__name(windowNamedLookup, "windowNamedLookup");
|
|
10894
|
+
function registerWindowName(el, attrName, value) {
|
|
10895
|
+
if (!value) return;
|
|
10896
|
+
if (attrName === "name") {
|
|
10897
|
+
if (!WINDOW_NAME_TAGS.has(el._tag)) return;
|
|
10898
|
+
WINDOW_NAME_VALUES.add(value);
|
|
10899
|
+
}
|
|
10900
|
+
if (WINDOW_NAMED_PROPS.has(value)) return;
|
|
10901
|
+
WINDOW_NAMED_PROPS.add(value);
|
|
10902
|
+
if (value in globalThis) return;
|
|
10903
|
+
Object.defineProperty(globalThis.__csimWindowNamedProps, value, {
|
|
10904
|
+
configurable: true,
|
|
10905
|
+
enumerable: false,
|
|
10906
|
+
get() {
|
|
10907
|
+
return windowNamedLookup(value);
|
|
10908
|
+
},
|
|
10909
|
+
// As with form named access, assignment shadows the getter with an own
|
|
10910
|
+
// property (configurable named properties); without a setter, strict-mode
|
|
10911
|
+
// `window.foo = x` for an id-named `foo` would throw.
|
|
10912
|
+
set(v) {
|
|
10913
|
+
Object.defineProperty(globalThis, value, { value: v, writable: true, enumerable: true, configurable: true });
|
|
10914
|
+
}
|
|
10915
|
+
});
|
|
10916
|
+
}
|
|
10917
|
+
__name(registerWindowName, "registerWindowName");
|
|
10918
|
+
function registerNamedAccess(el, attrName, value) {
|
|
10919
|
+
registerFormName(el, value);
|
|
10920
|
+
registerWindowName(el, attrName, value);
|
|
10921
|
+
}
|
|
10922
|
+
__name(registerNamedAccess, "registerNamedAccess");
|
|
10674
10923
|
var DocumentFragment = class extends Node {
|
|
10675
10924
|
static {
|
|
10676
10925
|
__name(this, "DocumentFragment");
|
|
@@ -11424,9 +11673,16 @@
|
|
|
11424
11673
|
}
|
|
11425
11674
|
}
|
|
11426
11675
|
const dest = this;
|
|
11676
|
+
const oldDoc = node.ownerDocument;
|
|
11427
11677
|
walkSubtree(node, (n) => {
|
|
11428
11678
|
n._ownerDoc = dest;
|
|
11429
11679
|
});
|
|
11680
|
+
const oldReg = oldDoc && oldDoc._liveRanges;
|
|
11681
|
+
if (oldReg && oldReg.size) {
|
|
11682
|
+
for (const r of [...oldReg]) {
|
|
11683
|
+
if (sameTreeContains(node, r.startContainer) || sameTreeContains(node, r.endContainer)) r._track();
|
|
11684
|
+
}
|
|
11685
|
+
}
|
|
11430
11686
|
return node;
|
|
11431
11687
|
}
|
|
11432
11688
|
// `document.implementation` — a per-document, cached `DOMImplementation`
|
|
@@ -12874,6 +13130,7 @@
|
|
|
12874
13130
|
askForReset(node);
|
|
12875
13131
|
if (oldParent) recordChildList(oldParent, [], [node], prevSib, nextSib);
|
|
12876
13132
|
recordChildList(parent, [node], []);
|
|
13133
|
+
if (isConnected(node)) fireCEMoveReactions(node);
|
|
12877
13134
|
return void 0;
|
|
12878
13135
|
}
|
|
12879
13136
|
__name(moveBeforeImpl, "moveBeforeImpl");
|
|
@@ -12937,12 +13194,12 @@
|
|
|
12937
13194
|
return el._attrNodeFor(key);
|
|
12938
13195
|
}
|
|
12939
13196
|
__name(makeAttr, "makeAttr");
|
|
12940
|
-
var { parseDocument, parseFragment } = installHtmlParser({ Document, Element, Text, Comment, DocumentFragment, DocumentType, createHtmlPageDocument });
|
|
13197
|
+
var { parseDocument, parseFragment } = installHtmlParser({ Document, Element, Text, Comment, DocumentFragment, DocumentType, createHtmlPageDocument, registerNamedAccess });
|
|
12941
13198
|
var { parseXml } = installXmlParser({ Element, Text, Comment, ProcessingInstruction, CDATASection, DocumentType });
|
|
12942
13199
|
|
|
12943
13200
|
// lib/capybara/simulated/js/src/abort.js
|
|
12944
13201
|
function defaultAbortReason() {
|
|
12945
|
-
return new
|
|
13202
|
+
return new DOMException2("signal is aborted without reason", "AbortError");
|
|
12946
13203
|
}
|
|
12947
13204
|
__name(defaultAbortReason, "defaultAbortReason");
|
|
12948
13205
|
var AbortSignal = class _AbortSignal extends EventTarget {
|
|
@@ -12974,7 +13231,7 @@
|
|
|
12974
13231
|
// AbortSignal.timeout(ms)}` is the canonical timeout idiom.
|
|
12975
13232
|
static timeout(ms) {
|
|
12976
13233
|
const s = new _AbortSignal();
|
|
12977
|
-
globalThis.setTimeout(() => s._markAborted(new
|
|
13234
|
+
globalThis.setTimeout(() => s._markAborted(new DOMException2("signal timed out", "TimeoutError")), Number(ms) || 0);
|
|
12978
13235
|
return s;
|
|
12979
13236
|
}
|
|
12980
13237
|
// Spec: returns a signal that aborts when any input signal aborts.
|
|
@@ -13917,6 +14174,109 @@
|
|
|
13917
14174
|
};
|
|
13918
14175
|
globalThis.EventSource = EventSource;
|
|
13919
14176
|
|
|
14177
|
+
// lib/capybara/simulated/js/src/websocket.js
|
|
14178
|
+
var byId2 = /* @__PURE__ */ new Map();
|
|
14179
|
+
globalThis.__csim_webSocketById = byId2;
|
|
14180
|
+
var WebSocket = class extends EventTarget {
|
|
14181
|
+
static {
|
|
14182
|
+
__name(this, "WebSocket");
|
|
14183
|
+
}
|
|
14184
|
+
constructor(url, protocols) {
|
|
14185
|
+
super();
|
|
14186
|
+
this.url = String(url);
|
|
14187
|
+
this.readyState = 0;
|
|
14188
|
+
this.bufferedAmount = 0;
|
|
14189
|
+
this.extensions = "";
|
|
14190
|
+
this.protocol = "";
|
|
14191
|
+
this.binaryType = "blob";
|
|
14192
|
+
this.onopen = null;
|
|
14193
|
+
this.onmessage = null;
|
|
14194
|
+
this.onclose = null;
|
|
14195
|
+
this.onerror = null;
|
|
14196
|
+
const list = protocols == null ? [] : Array.isArray(protocols) ? protocols.map(String) : [String(protocols)];
|
|
14197
|
+
this._id = globalThis.__csim_wsOpen(this.url, list) | 0;
|
|
14198
|
+
if (this._id > 0) byId2.set(this._id, this);
|
|
14199
|
+
}
|
|
14200
|
+
send(data) {
|
|
14201
|
+
if (this.readyState === 0) throw new DOMException("Failed to execute 'send' on 'WebSocket': Still in CONNECTING state.", "InvalidStateError");
|
|
14202
|
+
if (this.readyState !== 1) return;
|
|
14203
|
+
if (typeof data === "string") {
|
|
14204
|
+
globalThis.__csim_wsSend(this._id, data, false);
|
|
14205
|
+
return;
|
|
14206
|
+
}
|
|
14207
|
+
let bytes;
|
|
14208
|
+
if (data instanceof ArrayBuffer) bytes = new Uint8Array(data);
|
|
14209
|
+
else if (ArrayBuffer.isView(data)) bytes = new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
|
14210
|
+
else bytes = new Uint8Array(0);
|
|
14211
|
+
globalThis.__csim_wsSend(this._id, bytes, true);
|
|
14212
|
+
}
|
|
14213
|
+
close(code, reason) {
|
|
14214
|
+
if (this.readyState === 2 || this.readyState === 3) return;
|
|
14215
|
+
this.readyState = 2;
|
|
14216
|
+
if (this._id > 0) globalThis.__csim_wsClose(this._id, code == null ? 1e3 : code | 0, reason == null ? "" : String(reason));
|
|
14217
|
+
}
|
|
14218
|
+
};
|
|
14219
|
+
WebSocket.CONNECTING = 0;
|
|
14220
|
+
WebSocket.OPEN = 1;
|
|
14221
|
+
WebSocket.CLOSING = 2;
|
|
14222
|
+
WebSocket.CLOSED = 3;
|
|
14223
|
+
globalThis.__csim_deliverWebSocketEvents = function(events) {
|
|
14224
|
+
if (!events || !events.length) return 0;
|
|
14225
|
+
let delivered = 0;
|
|
14226
|
+
for (const e of events) {
|
|
14227
|
+
const ws = byId2.get(e.id | 0);
|
|
14228
|
+
if (!ws) continue;
|
|
14229
|
+
if (e.type === "__open") {
|
|
14230
|
+
if (ws.readyState === 0) {
|
|
14231
|
+
ws.readyState = 1;
|
|
14232
|
+
if (e.protocol) ws.protocol = String(e.protocol);
|
|
14233
|
+
dispatchWithOnHandler(ws, new Event("open"));
|
|
14234
|
+
delivered++;
|
|
14235
|
+
}
|
|
14236
|
+
continue;
|
|
14237
|
+
}
|
|
14238
|
+
if (e.type === "__close" || e.type === "__error") {
|
|
14239
|
+
if (e.type === "__error") {
|
|
14240
|
+
const err = new Event("error");
|
|
14241
|
+
if (e.message) try {
|
|
14242
|
+
err.message = String(e.message);
|
|
14243
|
+
} catch (_) {
|
|
14244
|
+
}
|
|
14245
|
+
dispatchWithOnHandler(ws, err);
|
|
14246
|
+
}
|
|
14247
|
+
if (ws.readyState !== 3) {
|
|
14248
|
+
ws.readyState = 3;
|
|
14249
|
+
const ev = new Event("close");
|
|
14250
|
+
try {
|
|
14251
|
+
ev.code = e.code == null ? 1006 : e.code | 0;
|
|
14252
|
+
ev.reason = e.reason == null ? "" : String(e.reason);
|
|
14253
|
+
ev.wasClean = e.type === "__close" && e.code != null;
|
|
14254
|
+
} catch (_) {
|
|
14255
|
+
}
|
|
14256
|
+
dispatchWithOnHandler(ws, ev);
|
|
14257
|
+
}
|
|
14258
|
+
byId2.delete(e.id | 0);
|
|
14259
|
+
delivered++;
|
|
14260
|
+
continue;
|
|
14261
|
+
}
|
|
14262
|
+
let data;
|
|
14263
|
+
if (e.binary) {
|
|
14264
|
+
const bytes = fetchedToBytes(e.data) || new Uint8Array(0);
|
|
14265
|
+
if (ws.binaryType === "arraybuffer") {
|
|
14266
|
+
data = bytes.byteOffset === 0 && bytes.byteLength === bytes.buffer.byteLength ? bytes.buffer : bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength);
|
|
14267
|
+
} else {
|
|
14268
|
+
data = typeof globalThis.Blob === "function" ? new globalThis.Blob([bytes]) : bytes.buffer;
|
|
14269
|
+
}
|
|
14270
|
+
} else {
|
|
14271
|
+
data = e.data == null ? "" : e.data;
|
|
14272
|
+
}
|
|
14273
|
+
dispatchWithOnHandler(ws, new MessageEvent("message", { data, origin: ws.url }));
|
|
14274
|
+
delivered++;
|
|
14275
|
+
}
|
|
14276
|
+
return delivered;
|
|
14277
|
+
};
|
|
14278
|
+
globalThis.WebSocket = WebSocket;
|
|
14279
|
+
|
|
13920
14280
|
// lib/capybara/simulated/js/src/request-body.js
|
|
13921
14281
|
function setContentTypeIfMissing(headers, value) {
|
|
13922
14282
|
if (!("Content-Type" in headers) && !("content-type" in headers)) {
|
|
@@ -15363,10 +15723,12 @@
|
|
|
15363
15723
|
const subAction = submitter && submitter._attrs && submitter._attrs.formaction;
|
|
15364
15724
|
const subMethod = submitter && submitter._attrs && submitter._attrs.formmethod;
|
|
15365
15725
|
const subEnctype = submitter && submitter._attrs && submitter._attrs.formenctype;
|
|
15726
|
+
const subTarget = submitter && submitter._attrs && submitter._attrs.formtarget;
|
|
15366
15727
|
return {
|
|
15367
15728
|
action: subAction != null ? subAction : form._attrs.action != null ? form._attrs.action : "",
|
|
15368
15729
|
method: (subMethod || form._attrs.method || "get").toLowerCase(),
|
|
15369
15730
|
enctype: (subEnctype || form._attrs.enctype || "application/x-www-form-urlencoded").toLowerCase(),
|
|
15731
|
+
target: subTarget != null ? subTarget : form._attrs.target != null ? form._attrs.target : "",
|
|
15370
15732
|
fields,
|
|
15371
15733
|
fileInputs
|
|
15372
15734
|
};
|
|
@@ -15667,6 +16029,28 @@
|
|
|
15667
16029
|
const n = handles.get(h);
|
|
15668
16030
|
return n != null && isConnected(n);
|
|
15669
16031
|
};
|
|
16032
|
+
globalThis.__csimEnsureFrameRealm = function(h) {
|
|
16033
|
+
const el = lookup(h);
|
|
16034
|
+
if (!el || el._tag !== "iframe" && el._tag !== "frame") return 0;
|
|
16035
|
+
if (typeof globalThis.__csimFrameWindow !== "function") return 0;
|
|
16036
|
+
globalThis.__csimFrameWindow(el);
|
|
16037
|
+
return el._frameRealmId != null ? el._frameRealmId : 0;
|
|
16038
|
+
};
|
|
16039
|
+
globalThis.__csimLocationHref = function() {
|
|
16040
|
+
return globalThis.location && globalThis.location.href || "";
|
|
16041
|
+
};
|
|
16042
|
+
globalThis.__csimRebindFrameRealm = function(h, oldId, newId) {
|
|
16043
|
+
const el = lookup(h);
|
|
16044
|
+
if (el) {
|
|
16045
|
+
el._frameRealmId = newId || null;
|
|
16046
|
+
el._frameWindow = null;
|
|
16047
|
+
}
|
|
16048
|
+
const ids = globalThis.__csimChildRealmIds;
|
|
16049
|
+
if (ids) {
|
|
16050
|
+
if (oldId) ids.delete(oldId);
|
|
16051
|
+
if (newId) ids.add(newId);
|
|
16052
|
+
}
|
|
16053
|
+
};
|
|
15670
16054
|
globalThis.__csimValue = function(h) {
|
|
15671
16055
|
const n = lookup(h);
|
|
15672
16056
|
if (!n || n.nodeType !== NODE_ELEMENT) return null;
|
|
@@ -17641,6 +18025,151 @@
|
|
|
17641
18025
|
}
|
|
17642
18026
|
};
|
|
17643
18027
|
globalThis.BroadcastChannel = BroadcastChannel;
|
|
18028
|
+
globalThis.__csimTransferDropAll = function(tokens) {
|
|
18029
|
+
const NS = globalThis.RustyRacer;
|
|
18030
|
+
if (!tokens || !NS || typeof NS.transferDrop !== "function") return;
|
|
18031
|
+
for (let i = 0; i < tokens.length; i++) NS.transferDrop(tokens[i]);
|
|
18032
|
+
};
|
|
18033
|
+
var __csimWindowProxies = /* @__PURE__ */ new Map();
|
|
18034
|
+
function csimMaybeTransferOut(data, transfer) {
|
|
18035
|
+
if (!transfer || !transfer.length) return null;
|
|
18036
|
+
const NS = globalThis.RustyRacer;
|
|
18037
|
+
if (!NS || typeof NS.transferOut !== "function") return null;
|
|
18038
|
+
const isAB = data instanceof ArrayBuffer;
|
|
18039
|
+
const isView = !isAB && ArrayBuffer.isView(data);
|
|
18040
|
+
if (!isAB && !isView) return null;
|
|
18041
|
+
const buf = isAB ? data : data.buffer;
|
|
18042
|
+
let inList = false;
|
|
18043
|
+
for (let i = 0; i < transfer.length; i++) {
|
|
18044
|
+
const t = transfer[i];
|
|
18045
|
+
if (t === buf || t && t.buffer === buf) {
|
|
18046
|
+
inList = true;
|
|
18047
|
+
break;
|
|
18048
|
+
}
|
|
18049
|
+
}
|
|
18050
|
+
if (!inList) return null;
|
|
18051
|
+
const token = NS.transferOut(data) | 0;
|
|
18052
|
+
if (token <= 0) return null;
|
|
18053
|
+
if (globalThis.__csim_transferIssued) globalThis.__csim_transferIssued(token);
|
|
18054
|
+
return isAB ? { __csimXfer: token, kind: "ArrayBuffer" } : {
|
|
18055
|
+
__csimXfer: token,
|
|
18056
|
+
kind: data.constructor && data.constructor.name || "Uint8Array",
|
|
18057
|
+
byteOffset: data.byteOffset,
|
|
18058
|
+
length: data.length
|
|
18059
|
+
};
|
|
18060
|
+
}
|
|
18061
|
+
__name(csimMaybeTransferOut, "csimMaybeTransferOut");
|
|
18062
|
+
function csimMaybeTransferIn(data) {
|
|
18063
|
+
if (!data || typeof data !== "object" || data.__csimXfer == null) return data;
|
|
18064
|
+
const NS = globalThis.RustyRacer;
|
|
18065
|
+
if (!NS || typeof NS.transferIn !== "function") return data;
|
|
18066
|
+
const ab = NS.transferIn(data.__csimXfer);
|
|
18067
|
+
if (!ab) return new ArrayBuffer(0);
|
|
18068
|
+
if (data.kind === "ArrayBuffer") return ab;
|
|
18069
|
+
const Ctor = globalThis[data.kind] || globalThis.Uint8Array;
|
|
18070
|
+
try {
|
|
18071
|
+
return new Ctor(ab, data.byteOffset || 0, data.length);
|
|
18072
|
+
} catch (_) {
|
|
18073
|
+
return new Uint8Array(ab);
|
|
18074
|
+
}
|
|
18075
|
+
}
|
|
18076
|
+
__name(csimMaybeTransferIn, "csimMaybeTransferIn");
|
|
18077
|
+
function csimWindowProxy(handle) {
|
|
18078
|
+
if (handle == null || handle === "") return null;
|
|
18079
|
+
let proxy = __csimWindowProxies.get(handle);
|
|
18080
|
+
if (proxy) return proxy;
|
|
18081
|
+
const location = {
|
|
18082
|
+
get href() {
|
|
18083
|
+
return globalThis.__csimWindowLocation(handle);
|
|
18084
|
+
},
|
|
18085
|
+
set href(v) {
|
|
18086
|
+
globalThis.__csimWindowSetLocation(handle, String(v));
|
|
18087
|
+
},
|
|
18088
|
+
assign(v) {
|
|
18089
|
+
globalThis.__csimWindowSetLocation(handle, String(v));
|
|
18090
|
+
},
|
|
18091
|
+
replace(v) {
|
|
18092
|
+
globalThis.__csimWindowSetLocation(handle, String(v));
|
|
18093
|
+
},
|
|
18094
|
+
toString() {
|
|
18095
|
+
return globalThis.__csimWindowLocation(handle);
|
|
18096
|
+
}
|
|
18097
|
+
};
|
|
18098
|
+
proxy = {
|
|
18099
|
+
get closed() {
|
|
18100
|
+
return !!globalThis.__csimWindowClosed(handle);
|
|
18101
|
+
},
|
|
18102
|
+
close() {
|
|
18103
|
+
globalThis.__csimWindowClose(handle);
|
|
18104
|
+
},
|
|
18105
|
+
focus() {
|
|
18106
|
+
},
|
|
18107
|
+
blur() {
|
|
18108
|
+
},
|
|
18109
|
+
// Cross-window postMessage. The data round-trips JS→Ruby→JS through the
|
|
18110
|
+
// host marshaller rather than a true structured-clone: plain
|
|
18111
|
+
// primitives/arrays/objects survive, but `undefined`→null, functions /
|
|
18112
|
+
// symbols drop (no DataCloneError is thrown), and prototypes/identity are
|
|
18113
|
+
// lost — fine for the JSON-ish payloads postMessage carries in practice.
|
|
18114
|
+
// `targetOrigin` is accepted but, like the single-origin model elsewhere,
|
|
18115
|
+
// not enforced.
|
|
18116
|
+
postMessage(data, targetOrigin, transfer) {
|
|
18117
|
+
const xfer = csimMaybeTransferOut(data, transfer);
|
|
18118
|
+
globalThis.__csimWindowPostMessage(handle, xfer || data, String(targetOrigin == null ? "*" : targetOrigin));
|
|
18119
|
+
detachTransferables(transfer);
|
|
18120
|
+
},
|
|
18121
|
+
get location() {
|
|
18122
|
+
return location;
|
|
18123
|
+
},
|
|
18124
|
+
set location(v) {
|
|
18125
|
+
location.href = v;
|
|
18126
|
+
},
|
|
18127
|
+
get window() {
|
|
18128
|
+
return proxy;
|
|
18129
|
+
},
|
|
18130
|
+
get self() {
|
|
18131
|
+
return proxy;
|
|
18132
|
+
},
|
|
18133
|
+
get __csimWindowHandle() {
|
|
18134
|
+
return handle;
|
|
18135
|
+
}
|
|
18136
|
+
};
|
|
18137
|
+
__csimWindowProxies.set(handle, proxy);
|
|
18138
|
+
return proxy;
|
|
18139
|
+
}
|
|
18140
|
+
__name(csimWindowProxy, "csimWindowProxy");
|
|
18141
|
+
globalThis.open = function(url, name, _features) {
|
|
18142
|
+
const fn = globalThis.__csimWindowOpen;
|
|
18143
|
+
if (typeof fn !== "function") return null;
|
|
18144
|
+
const handle = fn(url == null ? "" : String(url), name == null ? "" : String(name));
|
|
18145
|
+
return handle ? csimWindowProxy(handle) : null;
|
|
18146
|
+
};
|
|
18147
|
+
var __csimOpenerOverride;
|
|
18148
|
+
Object.defineProperty(globalThis, "opener", {
|
|
18149
|
+
configurable: true,
|
|
18150
|
+
get() {
|
|
18151
|
+
if (__csimOpenerOverride !== void 0) return __csimOpenerOverride;
|
|
18152
|
+
const fn = globalThis.__csimWindowOpener;
|
|
18153
|
+
const handle = typeof fn === "function" ? fn() : null;
|
|
18154
|
+
return handle ? csimWindowProxy(handle) : null;
|
|
18155
|
+
},
|
|
18156
|
+
set(v) {
|
|
18157
|
+
__csimOpenerOverride = v;
|
|
18158
|
+
}
|
|
18159
|
+
});
|
|
18160
|
+
globalThis.__csim_deliverWindowMessages = function(events) {
|
|
18161
|
+
if (!events || !events.length) return;
|
|
18162
|
+
for (const ev of events) {
|
|
18163
|
+
const source = ev && ev.sourceHandle ? csimWindowProxy(ev.sourceHandle) : null;
|
|
18164
|
+
dispatchWithOnHandler(globalThis, new MessageEvent("message", {
|
|
18165
|
+
data: csimMaybeTransferIn(ev ? ev.data : void 0),
|
|
18166
|
+
origin: ev && ev.origin || "",
|
|
18167
|
+
source,
|
|
18168
|
+
lastEventId: "",
|
|
18169
|
+
ports: []
|
|
18170
|
+
}));
|
|
18171
|
+
}
|
|
18172
|
+
};
|
|
17644
18173
|
globalThis.NodeFilter = {
|
|
17645
18174
|
SHOW_ALL: 4294967295,
|
|
17646
18175
|
SHOW_ELEMENT: 1,
|
|
@@ -18627,7 +19156,7 @@
|
|
|
18627
19156
|
(function() {
|
|
18628
19157
|
"use strict";
|
|
18629
19158
|
globalThis.Event = Event;
|
|
18630
|
-
globalThis.DOMException =
|
|
19159
|
+
globalThis.DOMException = DOMException2;
|
|
18631
19160
|
globalThis.CustomEvent = CustomEvent;
|
|
18632
19161
|
globalThis.MouseEvent = MouseEvent;
|
|
18633
19162
|
globalThis.KeyboardEvent = KeyboardEvent;
|
|
@@ -18677,7 +19206,7 @@
|
|
|
18677
19206
|
function fireCEConnect(subtree) {
|
|
18678
19207
|
walkSubtree(subtree, (el) => {
|
|
18679
19208
|
if (el.nodeType !== NODE_ELEMENT) return;
|
|
18680
|
-
if (!__inHTMLGrafting && el._tag === "script" && !el._csimRan) maybeRunScript(el);
|
|
19209
|
+
if (!__inHTMLGrafting && el._tag === "script" && !el._csimRan && el.isConnected) maybeRunScript(el);
|
|
18681
19210
|
if (el._tag === "link") maybeFireLinkLoad(el);
|
|
18682
19211
|
if (el._tag === "iframe" || el._tag === "frame") maybeFireFrameLoad(el);
|
|
18683
19212
|
ceTryConnect(el);
|
|
@@ -18739,9 +19268,9 @@
|
|
|
18739
19268
|
function maybeRunScript(el) {
|
|
18740
19269
|
const type = (el._attrs.type || "").toLowerCase();
|
|
18741
19270
|
if (type && type !== "text/javascript" && type !== "application/javascript" && type !== "application/x-javascript" && type !== "text/ecmascript") return;
|
|
18742
|
-
el._csimRan = true;
|
|
18743
19271
|
let body;
|
|
18744
19272
|
if (el._attrs.src) {
|
|
19273
|
+
el._csimRan = true;
|
|
18745
19274
|
try {
|
|
18746
19275
|
const resp = __rackFetch("GET", el._attrs.src, "", null, "follow");
|
|
18747
19276
|
if (!resp || resp.status >= 400) {
|
|
@@ -18753,12 +19282,14 @@
|
|
|
18753
19282
|
dispatchScriptLoad(el, false);
|
|
18754
19283
|
return;
|
|
18755
19284
|
}
|
|
19285
|
+
if (!body) {
|
|
19286
|
+
dispatchScriptLoad(el, true);
|
|
19287
|
+
return;
|
|
19288
|
+
}
|
|
18756
19289
|
} else {
|
|
18757
19290
|
body = scriptText(el);
|
|
18758
|
-
|
|
18759
|
-
|
|
18760
|
-
dispatchScriptLoad(el, true);
|
|
18761
|
-
return;
|
|
19291
|
+
if (!body) return;
|
|
19292
|
+
el._csimRan = true;
|
|
18762
19293
|
}
|
|
18763
19294
|
const label = el._attrs.src || "inline://" + hashStr(body);
|
|
18764
19295
|
let _ok = true;
|
|
@@ -18771,6 +19302,11 @@
|
|
|
18771
19302
|
dispatchScriptLoad(el, _ok);
|
|
18772
19303
|
}
|
|
18773
19304
|
__name(maybeRunScript, "maybeRunScript");
|
|
19305
|
+
globalThis.__csimScriptChildrenChanged = function(el) {
|
|
19306
|
+
if (!__inHTMLGrafting && el && el._tag === "script" && !el._csimRan && el.isConnected) {
|
|
19307
|
+
maybeRunScript(el);
|
|
19308
|
+
}
|
|
19309
|
+
};
|
|
18774
19310
|
globalThis.Document = Document;
|
|
18775
19311
|
globalThis.Element = Element;
|
|
18776
19312
|
installXPath(Document.prototype);
|
|
@@ -18817,6 +19353,7 @@
|
|
|
18817
19353
|
});
|
|
18818
19354
|
const ownerURL = (this._ownerDoc || globalThis.document).URL;
|
|
18819
19355
|
if (ownerURL) doc._url = ownerURL;
|
|
19356
|
+
doc._noBrowsingContext = true;
|
|
18820
19357
|
return doc;
|
|
18821
19358
|
}
|
|
18822
19359
|
};
|
|
@@ -18886,7 +19423,8 @@
|
|
|
18886
19423
|
}
|
|
18887
19424
|
}
|
|
18888
19425
|
if (typeof globalThis.__csim_createFrameRealm === "function" && globalThis.RustyRacer && typeof globalThis.RustyRacer.contextGlobal === "function") {
|
|
18889
|
-
const
|
|
19426
|
+
const parentId = typeof globalThis.RustyRacer.contextOf === "function" ? globalThis.RustyRacer.contextOf(globalThis) : 0;
|
|
19427
|
+
const id = globalThis.__csim_createFrameRealm(frameUrl, body, contentType, parentId);
|
|
18890
19428
|
if (id != null) {
|
|
18891
19429
|
frameEl._frameRealmId = id;
|
|
18892
19430
|
(globalThis.__csimChildRealmIds || (globalThis.__csimChildRealmIds = /* @__PURE__ */ new Set())).add(id);
|
|
@@ -19161,7 +19699,10 @@
|
|
|
19161
19699
|
} else {
|
|
19162
19700
|
body = scriptText(s);
|
|
19163
19701
|
}
|
|
19164
|
-
if (!body)
|
|
19702
|
+
if (!body) {
|
|
19703
|
+
s._csimRan = false;
|
|
19704
|
+
continue;
|
|
19705
|
+
}
|
|
19165
19706
|
const label = s._attrs.src || "inline://" + hashStr(body);
|
|
19166
19707
|
const prevCurrent = globalThis.document && globalThis.document._currentScript;
|
|
19167
19708
|
if (globalThis.document) globalThis.document._currentScript = s;
|