Backed out 6 changesets (bug 1811545, bug 1808894) for landing with leftover files from a puppeteer install (under remote/test/puppeteer/packages/puppeteer-core/). CLOSED TREE

Backed out changeset 7f0a872abb09 (bug 1811545)
Backed out changeset 41daafb5d75a (bug 1811545)
Backed out changeset 82dee6290057 (bug 1811545)
Backed out changeset 3e0178b3e0dc (bug 1811545)
Backed out changeset 55cec0043044 (bug 1811545)
Backed out changeset 75eaaf96d039 (bug 1808894)
This commit is contained in:
Stanca Serban 2023-01-27 04:37:23 +02:00
parent 9acfa9e0b9
commit 30b2ff14b6
882 changed files with 1131 additions and 122528 deletions

View file

@ -15,7 +15,6 @@ ChromeUtils.defineESModuleGetters(lazy, {
const ORDERED_NODE_ITERATOR_TYPE = 5;
const FIRST_ORDERED_NODE_TYPE = 9;
const DOCUMENT_FRAGMENT_NODE = 11;
const ELEMENT_NODE = 1;
const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
@ -448,12 +447,12 @@ element.findClosest = function(startNode, selector) {
};
/**
* Resolve element from specified web reference identifier.
* Resolve element from specified web element reference.
*
* @param {BrowsingContext} browsingContext
* The browsing context to retrieve the element from.
* @param {string} nodeId
* The WebReference uuid for a DOM element.
* @param {ElementIdentifier} nodeId
* The WebElement reference identifier for a DOM element.
* @param {NodeCache} nodeCache
* Node cache that holds already seen WebElement and ShadowRoot references.
*
@ -461,7 +460,8 @@ element.findClosest = function(startNode, selector) {
* The DOM element that the identifier was generated for.
*
* @throws {NoSuchElementError}
* If the element doesn't exist in the current browsing context.
* If element represented by reference <var>id</var> doesn't exist
* in the current browsing context.
* @throws {StaleElementReferenceError}
* If the element has gone stale, indicating its node document is no
* longer the active document or it is no longer attached to the DOM.
@ -469,78 +469,25 @@ element.findClosest = function(startNode, selector) {
element.getKnownElement = function(browsingContext, nodeId, nodeCache) {
if (!element.isNodeReferenceKnown(browsingContext, nodeId, nodeCache)) {
throw new lazy.error.NoSuchElementError(
`The element with the reference ${nodeId} is not known in the current browsing context`
);
}
const node = nodeCache.getNode(browsingContext, nodeId);
// Ensure the node is of the correct Node type.
if (node !== null && !element.isElement(node)) {
throw new lazy.error.NoSuchElementError(
`The element with the reference ${nodeId} is not of type HTMLElement`
lazy.pprint`The element reference of ${JSON.stringify(
nodeId.webElRef
)} is not known in the current browsing context`
);
}
// If null, which may be the case if the element has been unwrapped from a
// weak reference, it is always considered stale.
if (node === null || element.isStale(node)) {
const el = nodeCache.getNode(browsingContext, nodeId);
if (el === null || element.isStale(el)) {
throw new lazy.error.StaleElementReferenceError(
`The element with the reference ${nodeId} ` +
lazy.pprint`The element reference of ${el ||
JSON.stringify(nodeId.webElRef)} ` +
"is stale; either its node document is not the active document, " +
"or it is no longer connected to the DOM"
);
}
return node;
};
/**
* Resolve ShadowRoot from specified web reference identifier.
*
* @param {BrowsingContext} browsingContext
* The browsing context to retrieve the shadow root from.
* @param {string} nodeId
* The WebReference uuid for a ShadowRoot.
* @param {NodeCache} nodeCache
* Node cache that holds already seen WebElement and ShadowRoot references.
*
* @returns {ShadowRoot}
* The ShadowRoot that the identifier was generated for.
*
* @throws {NoSuchShadowRootError}
* If the ShadowRoot doesn't exist in the current browsing context.
* @throws {DetachedShadowRootError}
* If the ShadowRoot is detached, indicating its node document is no
* longer the active document or it is no longer attached to the DOM.
*/
element.getKnownShadowRoot = function(browsingContext, nodeId, nodeCache) {
if (!element.isNodeReferenceKnown(browsingContext, nodeId, nodeCache)) {
throw new lazy.error.NoSuchShadowRootError(
`The shadow root with the reference ${nodeId} is not known in the current browsing context`
);
}
const node = nodeCache.getNode(browsingContext, nodeId);
// Ensure the node is of the correct Node type.
if (node !== null && !element.isShadowRoot(node)) {
throw new lazy.error.NoSuchShadowRootError(
`The shadow root with the reference ${nodeId} is not of type ShadowRoot`
);
}
// If null, which may be the case if the element has been unwrapped from a
// weak reference, it is always considered stale.
if (node === null || element.isDetached(node)) {
throw new lazy.error.DetachedShadowRootError(
`The shadow root with the reference ${nodeId} ` +
"is detached; either its node document is not the active document, " +
"or it is no longer connected to the DOM"
);
}
return node;
return el;
};
/**
@ -569,24 +516,6 @@ element.isCollection = function(seq) {
}
};
/**
* Determines if <var>shadowRoot</var> is detached.
*
* A ShadowRoot is detached if its node document is not the active document
* or if the element node referred to as its host is stale.
*
* @param {ShadowRoot} shadowRoot
* ShadowRoot to check for detached state.
*
* @return {boolean}
* True if <var>shadowRoot</var> is detached, false otherwise.
*/
element.isDetached = function(shadowRoot) {
return (
!shadowRoot.ownerDocument.isActive() || element.isStale(shadowRoot.host)
);
};
/**
* Determines if the node reference is known for the given browsing context.
*
@ -638,7 +567,7 @@ element.isStale = function(el) {
return true;
}
return !el.ownerDocument.isActive() || !el.isConnected;
return !el.ownerGlobal.document.isActive() || !el.isConnected;
};
/**
@ -1187,19 +1116,17 @@ element.getShadowRoot = function(el) {
};
/**
* Ascertains whether <var>node</var> is a shadow root.
* Ascertains whether <var>obj</var> is a shadow root.
*
* @param {ShadowRoot} node
* @param {ShadowRoot} obj
* The node that will be checked to see if it has a shadow root
*
* @returns {boolean}
* True if <var>node</var> is a shadow root, false otherwise.
* True if <var>obj</var> is a shadow root, false otherwise.
*/
element.isShadowRoot = function(node) {
element.isShadowRoot = function(obj) {
return (
node &&
node.nodeType === DOCUMENT_FRAGMENT_NODE &&
node.containingShadowRoot == node
obj !== null && typeof obj == "object" && obj.containingShadowRoot == obj
);
};
@ -1213,7 +1140,13 @@ element.isShadowRoot = function(node) {
* True if <var>obj</var> is a DOM element, false otherwise.
*/
element.isDOMElement = function(obj) {
return obj && obj.nodeType == ELEMENT_NODE && !element.isXULElement(obj);
return (
typeof obj == "object" &&
obj !== null &&
"nodeType" in obj &&
obj.nodeType == ELEMENT_NODE &&
!element.isXULElement(obj)
);
};
/**
@ -1226,7 +1159,13 @@ element.isDOMElement = function(obj) {
* True if <var>obj</var> is a XULElement, false otherwise.
*/
element.isXULElement = function(obj) {
return obj && obj.nodeType === ELEMENT_NODE && obj.namespaceURI === XUL_NS;
return (
typeof obj == "object" &&
obj !== null &&
"nodeType" in obj &&
obj.nodeType === obj.ELEMENT_NODE &&
obj.namespaceURI === XUL_NS
);
};
/**
@ -1364,7 +1303,7 @@ export class WebReference {
* Returns a new {@link WebReference} reference for a DOM or XUL element,
* <code>WindowProxy</code>, or <code>ShadowRoot</code>.
*
* @param {(Element|ShadowRoot|WindowProxy|MockXULElement)} node
* @param {(Element|ShadowRoot|WindowProxy|XULElement)} node
* Node to construct a web element reference for.
* @param {string=} uuid
* Optional unique identifier of the WebReference if already known.

View file

@ -125,19 +125,20 @@ json.clone = function(value, nodeCache) {
// Evaluation of code might take place in mutable sandboxes, which are
// created to waive XRays by default. As such DOM nodes would have to be
// unwaived before accessing properties like "ownerGlobal" is possible.
//
// Until bug 1743788 is fixed there might be the possibility that more
// objects might need to be unwaived as well.
const isNode = Node.isInstance(value);
if (isNode) {
value = Cu.unwaiveXrays(value);
}
if (isNode && lazy.element.isElement(value)) {
// Convert DOM elements to WebReference instances.
if (
isNode &&
(lazy.element.isElement(value) || lazy.element.isShadowRoot(value))
) {
// Convert DOM elements (eg. HTMLElement, XULElement, et al) and
// ShadowRoot instances to WebReference references.
// Don't create a reference for stale elements.
if (lazy.element.isStale(value)) {
// Don't create a reference for stale elements.
throw new lazy.error.StaleElementReferenceError(
lazy.pprint`The element ${value} is no longer attached to the DOM`
);
@ -147,20 +148,6 @@ json.clone = function(value, nodeCache) {
return lazy.WebReference.from(value, nodeRef).toJSON();
}
if (isNode && lazy.element.isShadowRoot(value)) {
// Convert ShadowRoot instances to WebReference references.
if (lazy.element.isDetached(value)) {
// Don't create a reference for detached shadow roots.
throw new lazy.error.DetachedShadowRootError(
lazy.pprint`The ShadowRoot ${value} is no longer attached to the DOM`
);
}
const nodeRef = nodeCache.getOrCreateNodeReference(value);
return lazy.WebReference.from(value, nodeRef).toJSON();
}
if (typeof value.toJSON == "function") {
// custom JSON representation
let unsafeJSON;
@ -221,15 +208,10 @@ json.deserialize = function(value, nodeCache, win) {
// Create a WebReference based on the WebElement identifier.
const webRef = lazy.WebReference.fromJSON(value);
if (webRef instanceof lazy.ShadowRoot) {
return lazy.element.getKnownShadowRoot(
win.browsingContext,
webRef.uuid,
nodeCache
);
}
if (webRef instanceof lazy.WebElement) {
if (
webRef instanceof lazy.WebElement ||
webRef instanceof lazy.ShadowRoot
) {
return lazy.element.getKnownElement(
win.browsingContext,
webRef.uuid,

View file

@ -19,7 +19,7 @@ const MemoryReporter = Cc["@mozilla.org/memory-reporter-manager;1"].getService(
Ci.nsIMemoryReporterManager
);
class MockElement {
class Element {
constructor(tagName, attrs = {}) {
this.tagName = tagName;
this.localName = tagName;
@ -54,7 +54,58 @@ class MockElement {
}
}
class MockXULElement extends MockElement {
class DOMElement extends Element {
constructor(tagName, attrs = {}) {
super(tagName, attrs);
this.isConnected = true;
if (typeof this.namespaceURI == "undefined") {
this.namespaceURI = XHTML_NS;
}
if (typeof this.ownerDocument == "undefined") {
this.ownerDocument = { designMode: "off" };
}
if (typeof this.ownerDocument.documentElement == "undefined") {
this.ownerDocument.documentElement = { namespaceURI: XHTML_NS };
}
if (typeof this.type == "undefined") {
this.type = "text";
}
if (this.localName == "option") {
this.selected = false;
}
if (
this.localName == "input" &&
["checkbox", "radio"].includes(this.type)
) {
this.checked = false;
}
}
getBoundingClientRect() {
return {
top: 0,
left: 0,
width: 100,
height: 100,
};
}
}
class SVGElement extends Element {
constructor(tagName, attrs = {}) {
super(tagName, attrs);
this.namespaceURI = SVG_NS;
}
}
class XULElement extends Element {
constructor(tagName, attrs = {}) {
super(tagName, attrs);
this.namespaceURI = XUL_NS;
@ -68,66 +119,48 @@ class MockXULElement extends MockElement {
}
}
const xulEl = new MockXULElement("text");
const domEl = new DOMElement("p");
const svgEl = new SVGElement("rect");
const xulEl = new XULElement("text");
const domElInPrivilegedDocument = new MockElement("input", {
const domElInPrivilegedDocument = new Element("input", {
nodePrincipal: { isSystemPrincipal: true },
});
const xulElInPrivilegedDocument = new MockXULElement("text", {
const xulElInPrivilegedDocument = new XULElement("text", {
nodePrincipal: { isSystemPrincipal: true },
});
function setupTest() {
const browser = Services.appShell.createWindowlessBrowser(false);
browser.document.body.innerHTML = `
<div id="foo" style="margin: 50px">
<iframe></iframe>
<video></video>
<svg xmlns="http://www.w3.org/2000/svg"></svg>
<textarea></textarea>
</div>
`;
const divEl = browser.document.querySelector("div");
const svgEl = browser.document.querySelector("svg");
const textareaEl = browser.document.querySelector("textarea");
const videoEl = browser.document.querySelector("video");
const iframeEl = browser.document.querySelector("iframe");
const childEl = iframeEl.contentDocument.createElement("div");
iframeEl.contentDocument.body.appendChild(childEl);
const shadowRoot = videoEl.openOrClosedShadowRoot;
return {
browser,
nodeCache: new NodeCache(),
childEl,
divEl,
iframeEl,
shadowRoot,
svgEl,
textareaEl,
videoEl,
};
class WindowProxy {
get parent() {
return this;
}
get self() {
return this;
}
toString() {
return "[object Window]";
}
}
const domWin = new WindowProxy();
const domFrame = new (class extends WindowProxy {
get parent() {
return domWin;
}
})();
add_test(function test_findClosest() {
const { divEl, videoEl } = setupTest();
equal(element.findClosest(domEl, "foo"), null);
equal(element.findClosest(divEl, "foo"), null);
equal(element.findClosest(videoEl, "div"), divEl);
let foo = new DOMElement("foo");
let bar = new DOMElement("bar");
bar.parentNode = foo;
equal(element.findClosest(bar, "foo"), foo);
run_next_test();
});
add_test(function test_isSelected() {
const { browser, divEl } = setupTest();
const checkbox = browser.document.createElement("input");
checkbox.setAttribute("type", "checkbox");
let checkbox = new DOMElement("input", { type: "checkbox" });
ok(!element.isSelected(checkbox));
checkbox.checked = true;
ok(element.isSelected(checkbox));
@ -137,8 +170,7 @@ add_test(function test_isSelected() {
checkbox.checked = false;
ok(!element.isSelected(checkbox));
const option = browser.document.createElement("option");
let option = new DOMElement("option");
ok(!element.isSelected(option));
option.selected = true;
ok(element.isSelected(option));
@ -149,191 +181,121 @@ add_test(function test_isSelected() {
ok(!element.isSelected(option));
// anything else should not be selected
for (const type of [undefined, null, "foo", true, [], {}, divEl]) {
ok(!element.isSelected(type));
for (let typ of [domEl, undefined, null, "foo", true, [], {}]) {
ok(!element.isSelected(typ));
}
run_next_test();
});
add_test(function test_isElement() {
const { divEl, iframeEl, shadowRoot, svgEl } = setupTest();
ok(element.isElement(divEl));
ok(element.isElement(domEl));
ok(element.isElement(svgEl));
ok(element.isElement(xulEl));
ok(element.isElement(domElInPrivilegedDocument));
ok(element.isElement(xulElInPrivilegedDocument));
ok(!element.isElement(shadowRoot));
ok(!element.isElement(divEl.ownerGlobal));
ok(!element.isElement(iframeEl.contentWindow));
for (const type of [true, 42, {}, [], undefined, null]) {
ok(!element.isElement(type));
ok(!element.isElement(domWin));
ok(!element.isElement(domFrame));
for (let typ of [true, 42, {}, [], undefined, null]) {
ok(!element.isElement(typ));
}
run_next_test();
});
add_test(function test_isDOMElement() {
const { divEl, iframeEl, shadowRoot, svgEl } = setupTest();
ok(element.isDOMElement(divEl));
ok(element.isDOMElement(svgEl));
ok(element.isDOMElement(domEl));
ok(element.isDOMElement(domElInPrivilegedDocument));
ok(!element.isDOMElement(shadowRoot));
ok(!element.isDOMElement(divEl.ownerGlobal));
ok(!element.isDOMElement(iframeEl.contentWindow));
ok(element.isDOMElement(svgEl));
ok(!element.isDOMElement(xulEl));
ok(!element.isDOMElement(xulElInPrivilegedDocument));
for (const type of [true, 42, "foo", {}, [], undefined, null]) {
ok(!element.isDOMElement(type));
ok(!element.isDOMElement(domWin));
ok(!element.isDOMElement(domFrame));
for (let typ of [true, 42, {}, [], undefined, null]) {
ok(!element.isDOMElement(typ));
}
run_next_test();
});
add_test(function test_isXULElement() {
const { divEl, iframeEl, shadowRoot, svgEl } = setupTest();
ok(element.isXULElement(xulEl));
ok(element.isXULElement(xulElInPrivilegedDocument));
ok(!element.isXULElement(divEl));
ok(!element.isXULElement(domElInPrivilegedDocument));
ok(!element.isXULElement(domEl));
ok(!element.isXULElement(svgEl));
ok(!element.isXULElement(shadowRoot));
ok(!element.isXULElement(divEl.ownerGlobal));
ok(!element.isXULElement(iframeEl.contentWindow));
for (const type of [true, 42, "foo", {}, [], undefined, null]) {
ok(!element.isXULElement(type));
ok(!element.isXULElement(domWin));
ok(!element.isXULElement(domFrame));
for (let typ of [true, 42, {}, [], undefined, null]) {
ok(!element.isXULElement(typ));
}
run_next_test();
});
add_test(function test_isDOMWindow() {
const { divEl, iframeEl, shadowRoot, svgEl } = setupTest();
ok(element.isDOMWindow(divEl.ownerGlobal));
ok(element.isDOMWindow(iframeEl.contentWindow));
ok(!element.isDOMWindow(divEl));
ok(!element.isDOMWindow(svgEl));
ok(!element.isDOMWindow(shadowRoot));
ok(element.isDOMWindow(domWin));
ok(element.isDOMWindow(domFrame));
ok(!element.isDOMWindow(domEl));
ok(!element.isDOMWindow(domElInPrivilegedDocument));
ok(!element.isDOMWindow(svgEl));
ok(!element.isDOMWindow(xulEl));
ok(!element.isDOMWindow(xulElInPrivilegedDocument));
for (const type of [true, 42, {}, [], undefined, null]) {
ok(!element.isDOMWindow(type));
for (let typ of [true, 42, {}, [], undefined, null]) {
ok(!element.isDOMWindow(typ));
}
run_next_test();
});
add_test(function test_isShadowRoot() {
const { browser, divEl, iframeEl, shadowRoot, svgEl } = setupTest();
ok(element.isShadowRoot(shadowRoot));
ok(!element.isShadowRoot(divEl));
ok(!element.isShadowRoot(svgEl));
ok(!element.isShadowRoot(divEl.ownerGlobal));
ok(!element.isShadowRoot(iframeEl.contentWindow));
ok(!element.isShadowRoot(xulEl));
ok(!element.isShadowRoot(domElInPrivilegedDocument));
ok(!element.isShadowRoot(xulElInPrivilegedDocument));
for (const type of [true, 42, "foo", {}, [], undefined, null]) {
ok(!element.isShadowRoot(type));
}
const documentFragment = browser.document.createDocumentFragment();
ok(!element.isShadowRoot(documentFragment));
run_next_test();
});
add_test(function test_isReadOnly() {
const { browser, divEl, textareaEl } = setupTest();
const input = browser.document.createElement("input");
input.readOnly = true;
ok(element.isReadOnly(input));
textareaEl.readOnly = true;
ok(element.isReadOnly(textareaEl));
ok(!element.isReadOnly(divEl));
divEl.readOnly = true;
ok(!element.isReadOnly(divEl));
ok(!element.isReadOnly(null));
ok(!element.isReadOnly(domEl));
ok(!element.isReadOnly(new DOMElement("p", { readOnly: true })));
ok(element.isReadOnly(new DOMElement("input", { readOnly: true })));
ok(element.isReadOnly(new DOMElement("textarea", { readOnly: true })));
run_next_test();
});
add_test(function test_isDisabled() {
const { browser, divEl, svgEl } = setupTest();
ok(!element.isDisabled(new DOMElement("p")));
ok(!element.isDisabled(new SVGElement("rect", { disabled: true })));
ok(!element.isDisabled(new XULElement("browser", { disabled: true })));
const select = browser.document.createElement("select");
const option = browser.document.createElement("option");
select.appendChild(option);
select.disabled = true;
let select = new DOMElement("select", { disabled: true });
let option = new DOMElement("option");
option.parentNode = select;
ok(element.isDisabled(option));
const optgroup = browser.document.createElement("optgroup");
let optgroup = new DOMElement("optgroup", { disabled: true });
option.parentNode = optgroup;
ok(element.isDisabled(option));
optgroup.parentNode = select;
select.disabled = false;
ok(element.isDisabled(option));
select.disabled = false;
ok(!element.isDisabled(option));
for (const type of ["button", "input", "select", "textarea"]) {
const elem = browser.document.createElement(type);
ok(!element.isDisabled(elem));
elem.disabled = true;
ok(element.isDisabled(elem));
}
ok(!element.isDisabled(divEl));
svgEl.disabled = true;
ok(!element.isDisabled(svgEl));
ok(!element.isDisabled(new MockXULElement("browser", { disabled: true })));
ok(element.isDisabled(new DOMElement("button", { disabled: true })));
ok(element.isDisabled(new DOMElement("input", { disabled: true })));
ok(element.isDisabled(new DOMElement("select", { disabled: true })));
ok(element.isDisabled(new DOMElement("textarea", { disabled: true })));
run_next_test();
});
add_test(function test_isEditingHost() {
const { browser, divEl, svgEl } = setupTest();
ok(!element.isEditingHost(null));
ok(!element.isEditingHost(divEl));
divEl.contentEditable = true;
ok(element.isEditingHost(divEl));
ok(!element.isEditingHost(svgEl));
browser.document.designMode = "on";
ok(element.isEditingHost(svgEl));
ok(element.isEditingHost(new DOMElement("p", { isContentEditable: true })));
ok(
element.isEditingHost(
new DOMElement("p", { ownerDocument: { designMode: "on" } })
)
);
run_next_test();
});
add_test(function test_isEditable() {
const { browser, divEl, svgEl, textareaEl } = setupTest();
ok(!element.isEditable(null));
ok(!element.isEditable(domEl));
ok(!element.isEditable(new DOMElement("textarea", { readOnly: true })));
ok(!element.isEditable(new DOMElement("textarea", { disabled: true })));
for (let type of [
"checkbox",
@ -343,52 +305,34 @@ add_test(function test_isEditable() {
"button",
"image",
]) {
const input = browser.document.createElement("input");
input.setAttribute("type", type);
ok(!element.isEditable(input));
ok(!element.isEditable(new DOMElement("input", { type })));
}
ok(element.isEditable(new DOMElement("input", { type: "text" })));
ok(element.isEditable(new DOMElement("input")));
const input = browser.document.createElement("input");
ok(element.isEditable(input));
input.setAttribute("type", "text");
ok(element.isEditable(input));
ok(element.isEditable(textareaEl));
const textareaDisabled = browser.document.createElement("textarea");
textareaDisabled.disabled = true;
ok(!element.isEditable(textareaDisabled));
const textareaReadOnly = browser.document.createElement("textarea");
textareaReadOnly.readOnly = true;
ok(!element.isEditable(textareaReadOnly));
ok(!element.isEditable(divEl));
divEl.contentEditable = true;
ok(element.isEditable(divEl));
ok(!element.isEditable(svgEl));
browser.document.designMode = "on";
ok(element.isEditable(svgEl));
ok(element.isEditable(new DOMElement("textarea")));
ok(
element.isEditable(
new DOMElement("p", { ownerDocument: { designMode: "on" } })
)
);
ok(element.isEditable(new DOMElement("p", { isContentEditable: true })));
run_next_test();
});
add_test(function test_isMutableFormControlElement() {
const { browser, divEl, textareaEl } = setupTest();
ok(!element.isMutableFormControl(null));
ok(element.isMutableFormControl(textareaEl));
const textareaDisabled = browser.document.createElement("textarea");
textareaDisabled.disabled = true;
ok(!element.isMutableFormControl(textareaDisabled));
const textareaReadOnly = browser.document.createElement("textarea");
textareaReadOnly.readOnly = true;
ok(!element.isMutableFormControl(textareaReadOnly));
ok(
!element.isMutableFormControl(
new DOMElement("textarea", { readOnly: true })
)
);
ok(
!element.isMutableFormControl(
new DOMElement("textarea", { disabled: true })
)
);
const mutableStates = new Set([
"color",
@ -406,74 +350,76 @@ add_test(function test_isMutableFormControlElement() {
"url",
"week",
]);
for (const type of mutableStates) {
const input = browser.document.createElement("input");
input.setAttribute("type", type);
ok(element.isMutableFormControl(input));
for (let type of mutableStates) {
ok(element.isMutableFormControl(new DOMElement("input", { type })));
}
ok(element.isMutableFormControl(new DOMElement("textarea")));
const inputHidden = browser.document.createElement("input");
inputHidden.setAttribute("type", "hidden");
ok(!element.isMutableFormControl(inputHidden));
ok(!element.isMutableFormControl(divEl));
divEl.contentEditable = true;
ok(!element.isMutableFormControl(divEl));
browser.document.designMode = "on";
ok(!element.isMutableFormControl(divEl));
ok(
!element.isMutableFormControl(new DOMElement("input", { type: "hidden" }))
);
ok(!element.isMutableFormControl(new DOMElement("p")));
ok(
!element.isMutableFormControl(
new DOMElement("p", { isContentEditable: true })
)
);
ok(
!element.isMutableFormControl(
new DOMElement("p", { ownerDocument: { designMode: "on" } })
)
);
run_next_test();
});
add_test(function test_coordinates() {
const { divEl } = setupTest();
let p = element.coordinates(domEl);
ok(p.hasOwnProperty("x"));
ok(p.hasOwnProperty("y"));
equal("number", typeof p.x);
equal("number", typeof p.y);
let coords = element.coordinates(divEl);
ok(coords.hasOwnProperty("x"));
ok(coords.hasOwnProperty("y"));
equal(typeof coords.x, "number");
equal(typeof coords.y, "number");
deepEqual(element.coordinates(divEl), { x: 0, y: 0 });
deepEqual(element.coordinates(divEl, 10, 10), { x: 10, y: 10 });
deepEqual(element.coordinates(divEl, -5, -5), { x: -5, y: -5 });
deepEqual({ x: 50, y: 50 }, element.coordinates(domEl));
deepEqual({ x: 10, y: 10 }, element.coordinates(domEl, 10, 10));
deepEqual({ x: -5, y: -5 }, element.coordinates(domEl, -5, -5));
Assert.throws(() => element.coordinates(null), /node is null/);
Assert.throws(
() => element.coordinates(divEl, "string", undefined),
() => element.coordinates(domEl, "string", undefined),
/Offset must be a number/
);
Assert.throws(
() => element.coordinates(divEl, undefined, "string"),
() => element.coordinates(domEl, undefined, "string"),
/Offset must be a number/
);
Assert.throws(
() => element.coordinates(divEl, "string", "string"),
() => element.coordinates(domEl, "string", "string"),
/Offset must be a number/
);
Assert.throws(
() => element.coordinates(divEl, {}, undefined),
() => element.coordinates(domEl, {}, undefined),
/Offset must be a number/
);
Assert.throws(
() => element.coordinates(divEl, undefined, {}),
() => element.coordinates(domEl, undefined, {}),
/Offset must be a number/
);
Assert.throws(
() => element.coordinates(divEl, {}, {}),
() => element.coordinates(domEl, {}, {}),
/Offset must be a number/
);
Assert.throws(
() => element.coordinates(divEl, [], undefined),
() => element.coordinates(domEl, [], undefined),
/Offset must be a number/
);
Assert.throws(
() => element.coordinates(divEl, undefined, []),
() => element.coordinates(domEl, undefined, []),
/Offset must be a number/
);
Assert.throws(
() => element.coordinates(divEl, [], []),
() => element.coordinates(domEl, [], []),
/Offset must be a number/
);
@ -481,28 +427,25 @@ add_test(function test_coordinates() {
});
add_test(function test_isNodeReferenceKnown() {
const { browser, nodeCache, childEl, iframeEl, videoEl } = setupTest();
const browser = Services.appShell.createWindowlessBrowser(false);
const nodeCache = new NodeCache();
// Unknown node reference
ok(!element.isNodeReferenceKnown(browser.browsingContext, "foo", nodeCache));
// Known node reference
const videoElRef = nodeCache.getOrCreateNodeReference(videoEl);
ok(
element.isNodeReferenceKnown(browser.browsingContext, videoElRef, nodeCache)
);
const el = browser.document.createElement("video");
const elRef = nodeCache.getOrCreateNodeReference(el);
ok(element.isNodeReferenceKnown(browser.browsingContext, elRef, nodeCache));
// Different top-level browsing context
const browser2 = Services.appShell.createWindowlessBrowser(false);
ok(
!element.isNodeReferenceKnown(
browser2.browsingContext,
videoElRef,
nodeCache
)
);
ok(!element.isNodeReferenceKnown(browser2.browsingContext, elRef, nodeCache));
// Different child browsing context
const iframeEl = browser.document.createElement("iframe");
browser.document.body.appendChild(iframeEl);
const childEl = iframeEl.contentDocument.createElement("div");
const childElRef = nodeCache.getOrCreateNodeReference(childEl);
const childBrowsingContext = iframeEl.contentWindow.browsingContext;
ok(element.isNodeReferenceKnown(childBrowsingContext, childElRef, nodeCache));
@ -518,150 +461,64 @@ add_test(function test_isNodeReferenceKnown() {
});
add_test(function test_getKnownElement() {
const { browser, nodeCache, shadowRoot, videoEl } = setupTest();
const browser = Services.appShell.createWindowlessBrowser(false);
const nodeCache = new NodeCache();
// Unknown element reference
Assert.throws(() => {
element.getKnownElement(browser.browsingContext, "foo", nodeCache);
}, /NoSuchElementError/);
// With a ShadowRoot reference
const shadowRootRef = nodeCache.getOrCreateNodeReference(shadowRoot);
Assert.throws(() => {
element.getKnownElement(browser.browsingContext, shadowRootRef, nodeCache);
}, /NoSuchElementError/);
// Deleted element (eg. garbage collected)
let detachedEl = browser.document.createElement("div");
const detachedElRef = nodeCache.getOrCreateNodeReference(detachedEl);
let divEl = browser.document.createElement("div");
const divElRef = nodeCache.getOrCreateNodeReference(divEl);
// ... not connected to the DOM
Assert.throws(() => {
element.getKnownElement(browser.browsingContext, detachedElRef, nodeCache);
}, /StaleElementReferenceError/);
// ... element garbage collected
detachedEl = null;
divEl = null;
MemoryReporter.minimizeMemoryUsage(() => {
Assert.throws(() => {
element.getKnownElement(
browser.browsingContext,
detachedElRef,
nodeCache
);
element.getKnownElement(browser.browsingContext, divElRef, nodeCache);
}, /StaleElementReferenceError/);
run_next_test();
});
// Known element reference
const videoElRef = nodeCache.getOrCreateNodeReference(videoEl);
let imgEl = browser.document.createElement("img");
browser.document.body.appendChild(imgEl);
const imgElRef = nodeCache.getOrCreateNodeReference(imgEl);
equal(
element.getKnownElement(browser.browsingContext, videoElRef, nodeCache),
videoEl
element.getKnownElement(browser.browsingContext, imgElRef, nodeCache),
imgEl
);
});
add_test(function test_getKnownShadowRoot() {
const { browser, nodeCache, shadowRoot, videoEl } = setupTest();
const videoElRef = nodeCache.getOrCreateNodeReference(videoEl);
// Unknown ShadowRoot reference
Assert.throws(() => {
element.getKnownShadowRoot(browser.browsingContext, "foo", nodeCache);
}, /NoSuchShadowRootError/);
// With a HTMLElement reference
Assert.throws(() => {
element.getKnownShadowRoot(browser.browsingContext, videoElRef, nodeCache);
}, /NoSuchShadowRootError/);
// Known ShadowRoot reference
const shadowRootRef = nodeCache.getOrCreateNodeReference(shadowRoot);
equal(
element.getKnownShadowRoot(
browser.browsingContext,
shadowRootRef,
nodeCache
),
shadowRoot
);
// Detached ShadowRoot host
let el = browser.document.createElement("div");
let detachedShadowRoot = el.attachShadow({ mode: "open" });
detachedShadowRoot.innerHTML = "<input></input>";
const detachedShadowRootRef = nodeCache.getOrCreateNodeReference(
detachedShadowRoot
);
// ... not connected to the DOM
Assert.throws(() => {
element.getKnownShadowRoot(
browser.browsingContext,
detachedShadowRootRef,
nodeCache
);
}, /DetachedShadowRootError/);
// ... host and shadow root garbage collected
el = null;
detachedShadowRoot = null;
MemoryReporter.minimizeMemoryUsage(() => {
Assert.throws(() => {
element.getKnownShadowRoot(
browser.browsingContext,
detachedShadowRootRef,
nodeCache
);
}, /DetachedShadowRootError/);
run_next_test();
});
});
add_test(function test_isDetached() {
const { childEl, iframeEl } = setupTest();
let detachedShadowRoot = childEl.attachShadow({ mode: "open" });
detachedShadowRoot.innerHTML = "<input></input>";
// Connected to the DOM
ok(!element.isDetached(detachedShadowRoot));
// Node document (ownerDocument) is not the active document
iframeEl.remove();
ok(element.isDetached(detachedShadowRoot));
// host element is stale (eg. not connected)
detachedShadowRoot.host.remove();
equal(childEl.isConnected, false);
ok(element.isDetached(detachedShadowRoot));
run_next_test();
});
add_test(function test_isStale() {
const { childEl, iframeEl } = setupTest();
// Not connected to the DOM
ok(element.isStale(new Element("div")));
// Connected to the DOM
ok(!element.isStale(childEl));
const domDivEl = new DOMElement("div");
ok(!element.isStale(domDivEl));
// Not part of the active document
iframeEl.remove();
ok(element.isStale(childEl));
domDivEl.ownerGlobal = {
document: {
isActive() {
return false;
},
},
};
ok(element.isStale(domDivEl));
// Not connected to the DOM
childEl.remove();
ok(element.isStale(childEl));
// Without ownerGlobal
delete domDivEl.ownerGlobal;
ok(element.isStale(domDivEl));
run_next_test();
});
add_test(function test_WebReference_ctor() {
const el = new WebReference("foo");
let el = new WebReference("foo");
equal(el.uuid, "foo");
for (let t of [42, true, [], {}, null, undefined]) {
@ -672,8 +529,8 @@ add_test(function test_WebReference_ctor() {
});
add_test(function test_WebElemenet_is() {
const a = new WebReference("a");
const b = new WebReference("b");
let a = new WebReference("a");
let b = new WebReference("b");
ok(a.is(a));
ok(b.is(b));
@ -686,12 +543,10 @@ add_test(function test_WebElemenet_is() {
});
add_test(function test_WebReference_from() {
const { divEl, iframeEl } = setupTest();
ok(WebReference.from(divEl) instanceof WebElement);
ok(WebReference.from(domEl) instanceof WebElement);
ok(WebReference.from(xulEl) instanceof WebElement);
ok(WebReference.from(divEl.ownerGlobal) instanceof WebWindow);
ok(WebReference.from(iframeEl.contentWindow) instanceof WebFrame);
ok(WebReference.from(domWin) instanceof WebWindow);
ok(WebReference.from(domFrame) instanceof WebFrame);
ok(WebReference.from(domElInPrivilegedDocument) instanceof WebElement);
ok(WebReference.from(xulElInPrivilegedDocument) instanceof WebElement);
@ -703,15 +558,15 @@ add_test(function test_WebReference_from() {
add_test(function test_WebReference_fromJSON_WebElement() {
const { Identifier } = WebElement;
const ref = { [Identifier]: "foo" };
const webEl = WebReference.fromJSON(ref);
let ref = { [Identifier]: "foo" };
let webEl = WebReference.fromJSON(ref);
ok(webEl instanceof WebElement);
equal(webEl.uuid, "foo");
let identifierPrecedence = {
[Identifier]: "identifier-uuid",
};
const precedenceEl = WebReference.fromJSON(identifierPrecedence);
let precedenceEl = WebReference.fromJSON(identifierPrecedence);
ok(precedenceEl instanceof WebElement);
equal(precedenceEl.uuid, "identifier-uuid");
@ -719,9 +574,8 @@ add_test(function test_WebReference_fromJSON_WebElement() {
});
add_test(function test_WebReference_fromJSON_WebWindow() {
const ref = { [WebWindow.Identifier]: "foo" };
const win = WebReference.fromJSON(ref);
let ref = { [WebWindow.Identifier]: "foo" };
let win = WebReference.fromJSON(ref);
ok(win instanceof WebWindow);
equal(win.uuid, "foo");
@ -729,8 +583,8 @@ add_test(function test_WebReference_fromJSON_WebWindow() {
});
add_test(function test_WebReference_fromJSON_WebFrame() {
const ref = { [WebFrame.Identifier]: "foo" };
const frame = WebReference.fromJSON(ref);
let ref = { [WebFrame.Identifier]: "foo" };
let frame = WebReference.fromJSON(ref);
ok(frame instanceof WebFrame);
equal(frame.uuid, "foo");
@ -740,13 +594,11 @@ add_test(function test_WebReference_fromJSON_WebFrame() {
add_test(function test_WebReference_fromJSON_malformed() {
Assert.throws(() => WebReference.fromJSON({}), /InvalidArgumentError/);
Assert.throws(() => WebReference.fromJSON(null), /InvalidArgumentError/);
run_next_test();
});
add_test(function test_WebReference_fromUUID() {
const domWebEl = WebReference.fromUUID("bar");
let domWebEl = WebReference.fromUUID("bar");
ok(domWebEl instanceof WebElement);
equal(domWebEl.uuid, "bar");
@ -773,8 +625,8 @@ add_test(function test_generateUUID() {
add_test(function test_WebElement_toJSON() {
const { Identifier } = WebElement;
const el = new WebElement("foo");
const json = el.toJSON();
let el = new WebElement("foo");
let json = el.toJSON();
ok(Identifier in json);
equal(json[Identifier], "foo");
@ -785,7 +637,7 @@ add_test(function test_WebElement_toJSON() {
add_test(function test_WebElement_fromJSON() {
const { Identifier } = WebElement;
const el = WebElement.fromJSON({ [Identifier]: "foo" });
let el = WebElement.fromJSON({ [Identifier]: "foo" });
ok(el instanceof WebElement);
equal(el.uuid, "foo");
@ -795,9 +647,8 @@ add_test(function test_WebElement_fromJSON() {
});
add_test(function test_WebWindow_toJSON() {
const win = new WebWindow("foo");
const json = win.toJSON();
let win = new WebWindow("foo");
let json = win.toJSON();
ok(WebWindow.Identifier in json);
equal(json[WebWindow.Identifier], "foo");
@ -805,9 +656,8 @@ add_test(function test_WebWindow_toJSON() {
});
add_test(function test_WebWindow_fromJSON() {
const ref = { [WebWindow.Identifier]: "foo" };
const win = WebWindow.fromJSON(ref);
let ref = { [WebWindow.Identifier]: "foo" };
let win = WebWindow.fromJSON(ref);
ok(win instanceof WebWindow);
equal(win.uuid, "foo");
@ -815,9 +665,8 @@ add_test(function test_WebWindow_fromJSON() {
});
add_test(function test_WebFrame_toJSON() {
const frame = new WebFrame("foo");
const json = frame.toJSON();
let frame = new WebFrame("foo");
let json = frame.toJSON();
ok(WebFrame.Identifier in json);
equal(json[WebFrame.Identifier], "foo");
@ -825,9 +674,8 @@ add_test(function test_WebFrame_toJSON() {
});
add_test(function test_WebFrame_fromJSON() {
const ref = { [WebFrame.Identifier]: "foo" };
const win = WebFrame.fromJSON(ref);
let ref = { [WebFrame.Identifier]: "foo" };
let win = WebFrame.fromJSON(ref);
ok(win instanceof WebFrame);
equal(win.uuid, "foo");

View file

@ -4,7 +4,7 @@ const { json } = ChromeUtils.importESModule(
const { NodeCache } = ChromeUtils.importESModule(
"chrome://remote/content/shared/webdriver/NodeCache.sys.mjs"
);
const { ShadowRoot, WebElement, WebReference } = ChromeUtils.importESModule(
const { WebElement, WebReference } = ChromeUtils.importESModule(
"chrome://remote/content/marionette/element.sys.mjs"
);
@ -55,19 +55,7 @@ add_test(function test_clone_generalTypes() {
run_next_test();
});
add_test(function test_clone_ShadowRoot() {
const { nodeCache, shadowRoot } = setupTest();
const shadowRootRef = nodeCache.getOrCreateNodeReference(shadowRoot);
deepEqual(
json.clone(shadowRoot, nodeCache),
WebReference.from(shadowRoot, shadowRootRef).toJSON()
);
run_next_test();
});
add_test(function test_clone_WebElement() {
add_test(function test_clone_WebElements() {
const { htmlEl, nodeCache, svgEl } = setupTest();
const htmlElRef = nodeCache.getOrCreateNodeReference(htmlEl);
@ -196,31 +184,7 @@ add_test(function test_deserialize_generalTypes() {
run_next_test();
});
add_test(function test_deserialize_ShadowRoot() {
const { browser, nodeCache, shadowRoot } = setupTest();
const win = browser.document.ownerGlobal;
// Fails to resolve for unknown elements
const unknownShadowRootId = { [ShadowRoot.Identifier]: "foo" };
Assert.throws(() => {
json.deserialize(unknownShadowRootId, nodeCache, win);
}, /NoSuchShadowRootError/);
const shadowRootRef = nodeCache.getOrCreateNodeReference(shadowRoot);
const shadowRootEl = { [ShadowRoot.Identifier]: shadowRootRef };
// Fails to resolve for missing window reference
Assert.throws(() => json.deserialize(shadowRootEl, nodeCache), /TypeError/);
// Previously seen element is associated with original web element reference
const root = json.deserialize(shadowRootEl, nodeCache, win);
deepEqual(root, shadowRoot);
deepEqual(root, nodeCache.getNode(browser.browsingContext, shadowRootRef));
run_next_test();
});
add_test(function test_deserialize_WebElement() {
add_test(function test_deserialize_WebElements() {
const { browser, htmlEl, nodeCache } = setupTest();
const win = browser.document.ownerGlobal;
@ -232,7 +196,6 @@ add_test(function test_deserialize_WebElement() {
const htmlElRef = nodeCache.getOrCreateNodeReference(htmlEl);
const htmlWebEl = { [WebElement.Identifier]: htmlElRef };
// Fails to resolve for missing window reference
Assert.throws(() => json.deserialize(htmlWebEl, nodeCache), /TypeError/);

View file

@ -16,7 +16,6 @@ const ELEMENT_NODE = 1;
/**
* The class provides a mapping between DOM nodes and a unique node references.
* Supported types of nodes are Element and ShadowRoot.
*/
export class NodeCache {
#nodeIdMap;
@ -42,22 +41,16 @@ export class NodeCache {
}
/**
* Get or if not yet existent create a unique reference for an Element or
* ShadowRoot node.
* Get or if not yet existent create a unique reference for a DOM node.
*
* @param {Node} node
* The node to be added.
* The DOM node to be added.
*
* @return {string}
* The unique node reference for the DOM node.
*/
getOrCreateNodeReference(node) {
if (
!node ||
![DOCUMENT_FRAGMENT_NODE, ELEMENT_NODE].includes(node.nodeType) ||
(node.nodeType === DOCUMENT_FRAGMENT_NODE &&
node.containingShadowRoot !== node)
) {
if (![DOCUMENT_FRAGMENT_NODE, ELEMENT_NODE].includes(node?.nodeType)) {
throw new TypeError(`Failed to create node reference for ${node}`);
}

View file

@ -26,7 +26,7 @@ function setupTest() {
}
add_test(function getOrCreateNodeReference_invalid() {
const { browser, htmlEl, nodeCache } = setupTest();
const { htmlEl, nodeCache } = setupTest();
const invalidValues = [
null,
@ -37,7 +37,6 @@ add_test(function getOrCreateNodeReference_invalid() {
[],
{},
htmlEl.attributes[0],
browser.document.createDocumentFragment(),
];
for (const value of invalidValues) {

View file

@ -1 +0,0 @@
{"fullyTracked":false,"platform":"darwin","arch":"arm64","nodeVersion":"v16.19.0","command":"rollup --config rollup.third_party.config.js","extraArgs":[],"clean":false,"files":{"/Users/henrik/code/gecko/package-lock.json":"12d056a04f2c82f4cf2017c0f74c54bb455f33d48ca877901bd1f9e33ccac7c2","/Users/henrik/code/gecko/remote/test/puppeteer/package-lock.json":"8ca6d6b4f226876b554b60d7b2b4acd6c36bdcd1e22ec3908ea9bde5e6446a5f","/Users/henrik/code/gecko/remote/test/puppeteer/packages/puppeteer-core/lib/cjs/third_party/chromium-bidi/index.d.ts":"22b9b5bf4b4591ee7baa067237293e303a2c265d373f694e8e964083acb8281e","/Users/henrik/code/gecko/remote/test/puppeteer/packages/puppeteer-core/lib/cjs/third_party/chromium-bidi/index.js":"22b9b5bf4b4591ee7baa067237293e303a2c265d373f694e8e964083acb8281e","/Users/henrik/code/gecko/remote/test/puppeteer/packages/puppeteer-core/lib/cjs/third_party/mitt/index.d.ts":"2b0be0130102c0fb4348caa82b670e86195cc59b4427cb070655bb34b47813a4","/Users/henrik/code/gecko/remote/test/puppeteer/packages/puppeteer-core/lib/cjs/third_party/mitt/index.js":"2b0be0130102c0fb4348caa82b670e86195cc59b4427cb070655bb34b47813a4","/Users/henrik/code/gecko/remote/test/puppeteer/packages/puppeteer-core/lib/cjs/third_party/tsconfig.cjs.tsbuildinfo":"c61aebff790cebe184f7e0c624f2e36db0ab9a3ca5f70de29341bb2611a4482e","/Users/henrik/code/gecko/remote/test/puppeteer/packages/puppeteer-core/lib/esm/third_party/chromium-bidi/index.d.ts":"22b9b5bf4b4591ee7baa067237293e303a2c265d373f694e8e964083acb8281e","/Users/henrik/code/gecko/remote/test/puppeteer/packages/puppeteer-core/lib/esm/third_party/chromium-bidi/index.js":"22b9b5bf4b4591ee7baa067237293e303a2c265d373f694e8e964083acb8281e","/Users/henrik/code/gecko/remote/test/puppeteer/packages/puppeteer-core/lib/esm/third_party/mitt/index.d.ts":"2b0be0130102c0fb4348caa82b670e86195cc59b4427cb070655bb34b47813a4","/Users/henrik/code/gecko/remote/test/puppeteer/packages/puppeteer-core/lib/esm/third_party/mitt/index.js":"2b0be0130102c0fb4348caa82b670e86195cc59b4427cb070655bb34b47813a4","/Users/henrik/code/gecko/remote/test/puppeteer/packages/puppeteer-core/lib/esm/third_party/tsconfig.tsbuildinfo":"c61aebff790cebe184f7e0c624f2e36db0ab9a3ca5f70de29341bb2611a4482e"},"output":["lib/esm/third_party/**","lib/cjs/third_party/**","!.git/","!.hg/","!.svn/","!.wireit/","!.yarn/","!CVS/","!node_modules/"],"dependencies":{"[\"/Users/henrik/code/gecko/remote/test/puppeteer/packages/puppeteer-core\",\"build:tsc\"]":"073b4e4f446f61d9e1b9f97470832f3ecdc2f45ef8e73a7c6286876da1388b62"},"env":{}}

View file

@ -1 +0,0 @@
{"/Users/henrik/code/gecko/remote/test/puppeteer/packages/puppeteer-core/lib/cjs/third_party/chromium-bidi":{"t":"d"},"/Users/henrik/code/gecko/remote/test/puppeteer/packages/puppeteer-core/lib/cjs/third_party/chromium-bidi/index.d.ts":{"t":"f","m":1674768253585.4092,"s":748527},"/Users/henrik/code/gecko/remote/test/puppeteer/packages/puppeteer-core/lib/cjs/third_party/chromium-bidi/index.js":{"t":"f","m":1674768253216.283,"s":100337},"/Users/henrik/code/gecko/remote/test/puppeteer/packages/puppeteer-core/lib/cjs/third_party/mitt":{"t":"d"},"/Users/henrik/code/gecko/remote/test/puppeteer/packages/puppeteer-core/lib/cjs/third_party/mitt/index.d.ts":{"t":"f","m":1674768253591.5854,"s":1454},"/Users/henrik/code/gecko/remote/test/puppeteer/packages/puppeteer-core/lib/cjs/third_party/mitt/index.js":{"t":"f","m":1674768253224.2952,"s":350},"/Users/henrik/code/gecko/remote/test/puppeteer/packages/puppeteer-core/lib/cjs/third_party/tsconfig.cjs.tsbuildinfo":{"t":"f","m":1674768252513.1462,"s":36856},"/Users/henrik/code/gecko/remote/test/puppeteer/packages/puppeteer-core/lib/esm/third_party/chromium-bidi":{"t":"d"},"/Users/henrik/code/gecko/remote/test/puppeteer/packages/puppeteer-core/lib/esm/third_party/chromium-bidi/index.d.ts":{"t":"f","m":1674768253916.7559,"s":748527},"/Users/henrik/code/gecko/remote/test/puppeteer/packages/puppeteer-core/lib/esm/third_party/chromium-bidi/index.js":{"t":"f","m":1674768253703.1082,"s":100255},"/Users/henrik/code/gecko/remote/test/puppeteer/packages/puppeteer-core/lib/esm/third_party/mitt":{"t":"d"},"/Users/henrik/code/gecko/remote/test/puppeteer/packages/puppeteer-core/lib/esm/third_party/mitt/index.d.ts":{"t":"f","m":1674768253922.042,"s":1454},"/Users/henrik/code/gecko/remote/test/puppeteer/packages/puppeteer-core/lib/esm/third_party/mitt/index.js":{"t":"f","m":1674768253709.3767,"s":340},"/Users/henrik/code/gecko/remote/test/puppeteer/packages/puppeteer-core/lib/esm/third_party/tsconfig.tsbuildinfo":{"t":"f","m":1674768251199.5554,"s":36856}}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1 +0,0 @@
{"fullyTracked":false,"platform":"darwin","arch":"arm64","nodeVersion":"v16.19.0","command":"api-extractor run --local","extraArgs":[],"clean":true,"files":{"/Users/henrik/code/gecko/package-lock.json":"12d056a04f2c82f4cf2017c0f74c54bb455f33d48ca877901bd1f9e33ccac7c2","/Users/henrik/code/gecko/remote/test/puppeteer/package-lock.json":"8ca6d6b4f226876b554b60d7b2b4acd6c36bdcd1e22ec3908ea9bde5e6446a5f","/Users/henrik/code/gecko/remote/test/puppeteer/packages/puppeteer-core/api-extractor.json":"37b279a1d8f626c3bf11f729ccf235b8a9ef96b7a771120f2cdb963b4bb7c4ce","/Users/henrik/code/gecko/remote/test/puppeteer/packages/puppeteer-core/tsconfig.json":"40a7b3a76f221b6794459d8bc6cdb3d1ae05fba99616ab4692bb5b6ac3147782"},"output":["lib/types.d.ts","!.git/","!.hg/","!.svn/","!.wireit/","!.yarn/","!CVS/","!node_modules/"],"dependencies":{"[\"/Users/henrik/code/gecko/remote/test/puppeteer/packages/puppeteer-core\",\"build:tsc\"]":"073b4e4f446f61d9e1b9f97470832f3ecdc2f45ef8e73a7c6286876da1388b62"},"env":{}}

View file

@ -1 +0,0 @@
{"/Users/henrik/code/gecko/remote/test/puppeteer/packages/puppeteer-core/lib/types.d.ts":{"t":"f","m":1674768255847.1177,"s":264150}}

View file

@ -1 +0,0 @@
{"fullyTracked":false,"platform":"darwin","arch":"arm64","nodeVersion":"v16.19.0","command":"rimraf lib/esm/third_party lib/cjs/third_party","extraArgs":[],"clean":true,"files":{},"output":[],"dependencies":{},"env":{}}

View file

@ -1 +0,0 @@
{"fullyTracked":false,"platform":"darwin","arch":"arm64","nodeVersion":"v16.19.0","command":"eslint --cache-location .eslintcache --cache --ext=ts --no-ignore --no-eslintrc -c=../../.eslintrc.types.cjs --fix lib/types.d.ts","extraArgs":[],"clean":false,"files":{"/Users/henrik/code/gecko/package-lock.json":"12d056a04f2c82f4cf2017c0f74c54bb455f33d48ca877901bd1f9e33ccac7c2","/Users/henrik/code/gecko/remote/test/puppeteer/.eslintrc.types.cjs":"b6b6571f423dd59349cc408f59a796674959b58db0557a0264720c9dd16be49d","/Users/henrik/code/gecko/remote/test/puppeteer/package-lock.json":"8ca6d6b4f226876b554b60d7b2b4acd6c36bdcd1e22ec3908ea9bde5e6446a5f","/Users/henrik/code/gecko/remote/test/puppeteer/packages/puppeteer-core/lib/types.d.ts":"4b0d03748b104790791089a416ff78350aabf2a9094c7780c372dcf959699c53"},"output":["lib/types.d.ts","!.git/","!.hg/","!.svn/","!.wireit/","!.yarn/","!CVS/","!node_modules/"],"dependencies":{"[\"/Users/henrik/code/gecko/remote/test/puppeteer/packages/puppeteer-core\",\"build:types\"]":"64ec1373b13e67658c3b733dd2ba42a81c82cc474b726912ee8d83d928e70289"},"env":{}}

View file

@ -1 +0,0 @@
{"/Users/henrik/code/gecko/remote/test/puppeteer/packages/puppeteer-core/lib/types.d.ts":{"t":"f","m":1674768257088.7676,"s":264000}}

View file

@ -1 +0,0 @@
{"fullyTracked":false,"platform":"darwin","arch":"arm64","nodeVersion":"v16.19.0","command":"tsx ../../tools/generate_module_package_json.ts lib/esm/package.json","extraArgs":[],"clean":"if-file-deleted","files":{},"output":["lib/esm/package.json","!.git/","!.hg/","!.svn/","!.wireit/","!.yarn/","!CVS/","!node_modules/"],"dependencies":{"[\"/Users/henrik/code/gecko/remote/test/puppeteer/packages/puppeteer-core\",\"build:tsc\"]":"073b4e4f446f61d9e1b9f97470832f3ecdc2f45ef8e73a7c6286876da1388b62"},"env":{}}

View file

@ -1 +0,0 @@
{"/Users/henrik/code/gecko/remote/test/puppeteer/packages/puppeteer-core/lib/esm/package.json":{"t":"f","m":1674768252880.2676,"s":18}}

View file

@ -1 +0,0 @@
{"fullyTracked":true,"platform":"darwin","arch":"arm64","nodeVersion":"v16.19.0","command":"tsx tools/generate_sources.ts","extraArgs":[],"clean":true,"files":{"/Users/henrik/code/gecko/package-lock.json":"12d056a04f2c82f4cf2017c0f74c54bb455f33d48ca877901bd1f9e33ccac7c2","/Users/henrik/code/gecko/remote/test/puppeteer/package-lock.json":"8ca6d6b4f226876b554b60d7b2b4acd6c36bdcd1e22ec3908ea9bde5e6446a5f","/Users/henrik/code/gecko/remote/test/puppeteer/packages/puppeteer-core/src/templates/injected.ts.tmpl":"dbd1ff3070c2f98f239b394837e70b74941ea25c0b766182c7ade6f13aad2303","/Users/henrik/code/gecko/remote/test/puppeteer/packages/puppeteer-core/src/templates/version.ts.tmpl":"a5f6d16aeb816573124feeebf87980c52fd0b1505fde97da1d36fa2b352ba363","/Users/henrik/code/gecko/remote/test/puppeteer/packages/puppeteer-core/tools/generate_sources.ts":"e3b1e37389b263cd2e99ad95278883c7b8661a16d810bf2026648a11adc54b11"},"output":["src/generated/**","!.git/","!.hg/","!.svn/","!.wireit/","!.yarn/","!CVS/","!node_modules/"],"dependencies":{},"env":{}}

View file

@ -1 +0,0 @@
{"/Users/henrik/code/gecko/remote/test/puppeteer/packages/puppeteer-core/src/generated/injected.ts":{"t":"f","m":1674768225663.2888,"s":13922},"/Users/henrik/code/gecko/remote/test/puppeteer/packages/puppeteer-core/src/generated/version.ts":{"t":"f","m":1674768225663.256,"s":61}}

View file

@ -1,337 +0,0 @@
/**
* Copyright 2017 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/// <reference types="node" />
import { ChildProcess } from 'child_process';
import { Protocol } from 'devtools-protocol';
import { EventEmitter } from '../common/EventEmitter.js';
import type { Page } from './Page.js';
import type { Target } from '../common/Target.js';
import type { BrowserContext } from './BrowserContext.js';
/**
* BrowserContext options.
*
* @public
*/
export interface BrowserContextOptions {
/**
* Proxy server with optional port to use for all requests.
* Username and password can be set in `Page.authenticate`.
*/
proxyServer?: string;
/**
* Bypass the proxy for the given list of hosts.
*/
proxyBypassList?: string[];
}
/**
* @internal
*/
export type BrowserCloseCallback = () => Promise<void> | void;
/**
* @public
*/
export type TargetFilterCallback = (target: Protocol.Target.TargetInfo) => boolean;
/**
* @internal
*/
export type IsPageTargetCallback = (target: Protocol.Target.TargetInfo) => boolean;
/**
* @internal
*/
export declare const WEB_PERMISSION_TO_PROTOCOL_PERMISSION: Map<Permission, Protocol.Browser.PermissionType>;
/**
* @public
*/
export type Permission = 'geolocation' | 'midi' | 'notifications' | 'camera' | 'microphone' | 'background-sync' | 'ambient-light-sensor' | 'accelerometer' | 'gyroscope' | 'magnetometer' | 'accessibility-events' | 'clipboard-read' | 'clipboard-write' | 'payment-handler' | 'persistent-storage' | 'idle-detection' | 'midi-sysex';
/**
* @public
*/
export interface WaitForTargetOptions {
/**
* Maximum wait time in milliseconds. Pass `0` to disable the timeout.
* @defaultValue 30 seconds.
*/
timeout?: number;
}
/**
* All the events a {@link Browser | browser instance} may emit.
*
* @public
*/
export declare const enum BrowserEmittedEvents {
/**
* Emitted when Puppeteer gets disconnected from the Chromium instance. This
* might happen because of one of the following:
*
* - Chromium is closed or crashed
*
* - The {@link Browser.disconnect | browser.disconnect } method was called.
*/
Disconnected = "disconnected",
/**
* Emitted when the url of a target changes. Contains a {@link Target} instance.
*
* @remarks
*
* Note that this includes target changes in incognito browser contexts.
*/
TargetChanged = "targetchanged",
/**
* Emitted when a target is created, for example when a new page is opened by
* {@link https://developer.mozilla.org/en-US/docs/Web/API/Window/open | window.open}
* or by {@link Browser.newPage | browser.newPage}
*
* Contains a {@link Target} instance.
*
* @remarks
*
* Note that this includes target creations in incognito browser contexts.
*/
TargetCreated = "targetcreated",
/**
* Emitted when a target is destroyed, for example when a page is closed.
* Contains a {@link Target} instance.
*
* @remarks
*
* Note that this includes target destructions in incognito browser contexts.
*/
TargetDestroyed = "targetdestroyed"
}
/**
* A Browser is created when Puppeteer connects to a Chromium instance, either through
* {@link PuppeteerNode.launch} or {@link Puppeteer.connect}.
*
* @remarks
*
* The Browser class extends from Puppeteer's {@link EventEmitter} class and will
* emit various events which are documented in the {@link BrowserEmittedEvents} enum.
*
* @example
* An example of using a {@link Browser} to create a {@link Page}:
*
* ```ts
* import puppeteer from 'puppeteer';
*
* (async () => {
* const browser = await puppeteer.launch();
* const page = await browser.newPage();
* await page.goto('https://example.com');
* await browser.close();
* })();
* ```
*
* @example
* An example of disconnecting from and reconnecting to a {@link Browser}:
*
* ```ts
* import puppeteer from 'puppeteer';
*
* (async () => {
* const browser = await puppeteer.launch();
* // Store the endpoint to be able to reconnect to Chromium
* const browserWSEndpoint = browser.wsEndpoint();
* // Disconnect puppeteer from Chromium
* browser.disconnect();
*
* // Use the endpoint to reestablish a connection
* const browser2 = await puppeteer.connect({browserWSEndpoint});
* // Close Chromium
* await browser2.close();
* })();
* ```
*
* @public
*/
export declare class Browser extends EventEmitter {
/**
* @internal
*/
constructor();
/**
* @internal
*/
_attach(): Promise<void>;
/**
* @internal
*/
_detach(): void;
/**
* @internal
*/
get _targets(): Map<string, Target>;
/**
* The spawned browser process. Returns `null` if the browser instance was created with
* {@link Puppeteer.connect}.
*/
process(): ChildProcess | null;
/**
* @internal
*/
_getIsPageTargetCallback(): IsPageTargetCallback | undefined;
/**
* Creates a new incognito browser context. This won't share cookies/cache with other
* browser contexts.
*
* @example
*
* ```ts
* (async () => {
* const browser = await puppeteer.launch();
* // Create a new incognito browser context.
* const context = await browser.createIncognitoBrowserContext();
* // Create a new page in a pristine context.
* const page = await context.newPage();
* // Do stuff
* await page.goto('https://example.com');
* })();
* ```
*/
createIncognitoBrowserContext(options?: BrowserContextOptions): Promise<BrowserContext>;
/**
* Returns an array of all open browser contexts. In a newly created browser, this will
* return a single instance of {@link BrowserContext}.
*/
browserContexts(): BrowserContext[];
/**
* Returns the default browser context. The default browser context cannot be closed.
*/
defaultBrowserContext(): BrowserContext;
/**
* @internal
*/
_disposeContext(contextId?: string): Promise<void>;
/**
* The browser websocket endpoint which can be used as an argument to
* {@link Puppeteer.connect}.
*
* @returns The Browser websocket url.
*
* @remarks
*
* The format is `ws://${host}:${port}/devtools/browser/<id>`.
*
* You can find the `webSocketDebuggerUrl` from `http://${host}:${port}/json/version`.
* Learn more about the
* {@link https://chromedevtools.github.io/devtools-protocol | devtools protocol} and
* the {@link
* https://chromedevtools.github.io/devtools-protocol/#how-do-i-access-the-browser-target
* | browser endpoint}.
*/
wsEndpoint(): string;
/**
* Promise which resolves to a new {@link Page} object. The Page is created in
* a default browser context.
*/
newPage(): Promise<Page>;
/**
* @internal
*/
_createPageInContext(contextId?: string): Promise<Page>;
/**
* All active targets inside the Browser. In case of multiple browser contexts, returns
* an array with all the targets in all browser contexts.
*/
targets(): Target[];
/**
* The target associated with the browser.
*/
target(): Target;
/**
* Searches for a target in all browser contexts.
*
* @param predicate - A function to be run for every target.
* @returns The first target found that matches the `predicate` function.
*
* @example
*
* An example of finding a target for a page opened via `window.open`:
*
* ```ts
* await page.evaluate(() => window.open('https://www.example.com/'));
* const newWindowTarget = await browser.waitForTarget(
* target => target.url() === 'https://www.example.com/'
* );
* ```
*/
waitForTarget(predicate: (x: Target) => boolean | Promise<boolean>, options?: WaitForTargetOptions): Promise<Target>;
/**
* An array of all open pages inside the Browser.
*
* @remarks
*
* In case of multiple browser contexts, returns an array with all the pages in all
* browser contexts. Non-visible pages, such as `"background_page"`, will not be listed
* here. You can find them using {@link Target.page}.
*/
pages(): Promise<Page[]>;
/**
* A string representing the browser name and version.
*
* @remarks
*
* For headless Chromium, this is similar to `HeadlessChrome/61.0.3153.0`. For
* non-headless, this is similar to `Chrome/61.0.3153.0`.
*
* The format of browser.version() might change with future releases of Chromium.
*/
version(): Promise<string>;
/**
* The browser's original user agent. Pages can override the browser user agent with
* {@link Page.setUserAgent}.
*/
userAgent(): Promise<string>;
/**
* Closes Chromium and all of its pages (if any were opened). The {@link Browser} object
* itself is considered to be disposed and cannot be used anymore.
*/
close(): Promise<void>;
/**
* Disconnects Puppeteer from the browser, but leaves the Chromium process running.
* After calling `disconnect`, the {@link Browser} object is considered disposed and
* cannot be used anymore.
*/
disconnect(): void;
/**
* Indicates that the browser is connected.
*/
isConnected(): boolean;
}
/**
* @public
*/
export declare const enum BrowserContextEmittedEvents {
/**
* Emitted when the url of a target inside the browser context changes.
* Contains a {@link Target} instance.
*/
TargetChanged = "targetchanged",
/**
* Emitted when a target is created within the browser context, for example
* when a new page is opened by
* {@link https://developer.mozilla.org/en-US/docs/Web/API/Window/open | window.open}
* or by {@link BrowserContext.newPage | browserContext.newPage}
*
* Contains a {@link Target} instance.
*/
TargetCreated = "targetcreated",
/**
* Emitted when a target is destroyed within the browser context, for example
* when a page is closed. Contains a {@link Target} instance.
*/
TargetDestroyed = "targetdestroyed"
}
//# sourceMappingURL=Browser.d.ts.map

View file

@ -1 +0,0 @@
{"version":3,"file":"Browser.d.ts","sourceRoot":"","sources":["../../../../src/api/Browser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;AAIH,OAAO,EAAC,YAAY,EAAC,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAC,QAAQ,EAAC,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAC,YAAY,EAAC,MAAM,2BAA2B,CAAC;AACvD,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,qBAAqB,CAAC;AAChD,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,qBAAqB,CAAC;AAExD;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AAE9D;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,CACjC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,UAAU,KAC/B,OAAO,CAAC;AAEb;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,CACjC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,UAAU,KAC/B,OAAO,CAAC;AAEb;;GAEG;AACH,eAAO,MAAM,qCAAqC,kDAwBhD,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,UAAU,GAClB,aAAa,GACb,MAAM,GACN,eAAe,GACf,QAAQ,GACR,YAAY,GACZ,iBAAiB,GACjB,sBAAsB,GACtB,eAAe,GACf,WAAW,GACX,cAAc,GACd,sBAAsB,GACtB,gBAAgB,GAChB,iBAAiB,GACjB,iBAAiB,GACjB,oBAAoB,GACpB,gBAAgB,GAChB,YAAY,CAAC;AAEjB;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;GAIG;AACH,0BAAkB,oBAAoB;IACpC;;;;;;;OAOG;IACH,YAAY,iBAAiB;IAE7B;;;;;;OAMG;IACH,aAAa,kBAAkB;IAE/B;;;;;;;;;;OAUG;IACH,aAAa,kBAAkB;IAC/B;;;;;;;OAOG;IACH,eAAe,oBAAoB;CACpC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,qBAAa,OAAQ,SAAQ,YAAY;IACvC;;OAEG;;IAKH;;OAEG;IACH,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAIxB;;OAEG;IACH,OAAO,IAAI,IAAI;IAIf;;OAEG;IACH,IAAI,QAAQ,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAElC;IAED;;;OAGG;IACH,OAAO,IAAI,YAAY,GAAG,IAAI;IAI9B;;OAEG;IACH,wBAAwB,IAAI,oBAAoB,GAAG,SAAS;IAI5D;;;;;;;;;;;;;;;;;OAiBG;IACH,6BAA6B,CAC3B,OAAO,CAAC,EAAE,qBAAqB,GAC9B,OAAO,CAAC,cAAc,CAAC;IAK1B;;;OAGG;IACH,eAAe,IAAI,cAAc,EAAE;IAInC;;OAEG;IACH,qBAAqB,IAAI,cAAc;IAIvC;;OAEG;IACH,eAAe,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKlD;;;;;;;;;;;;;;;;OAgBG;IACH,UAAU,IAAI,MAAM;IAIpB;;;OAGG;IACH,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAIxB;;OAEG;IACH,oBAAoB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKvD;;;OAGG;IACH,OAAO,IAAI,MAAM,EAAE;IAInB;;OAEG;IACH,MAAM,IAAI,MAAM;IAIhB;;;;;;;;;;;;;;;;OAgBG;IACH,aAAa,CACX,SAAS,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,EACpD,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,CAAC,MAAM,CAAC;IAKlB;;;;;;;;OAQG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;IAIxB;;;;;;;;;OASG;IACH,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC;IAI1B;;;OAGG;IACH,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC;IAI5B;;;OAGG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAItB;;;;OAIG;IACH,UAAU,IAAI,IAAI;IAIlB;;OAEG;IACH,WAAW,IAAI,OAAO;CAGvB;AACD;;GAEG;AACH,0BAAkB,2BAA2B;IAC3C;;;OAGG;IACH,aAAa,kBAAkB;IAE/B;;;;;;;OAOG;IACH,aAAa,kBAAkB;IAC/B;;;OAGG;IACH,eAAe,oBAAoB;CACpC"}

View file

@ -1,248 +0,0 @@
"use strict";
/**
* Copyright 2017 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.Browser = exports.WEB_PERMISSION_TO_PROTOCOL_PERMISSION = void 0;
const EventEmitter_js_1 = require("../common/EventEmitter.js");
/**
* @internal
*/
exports.WEB_PERMISSION_TO_PROTOCOL_PERMISSION = new Map([
['geolocation', 'geolocation'],
['midi', 'midi'],
['notifications', 'notifications'],
// TODO: push isn't a valid type?
// ['push', 'push'],
['camera', 'videoCapture'],
['microphone', 'audioCapture'],
['background-sync', 'backgroundSync'],
['ambient-light-sensor', 'sensors'],
['accelerometer', 'sensors'],
['gyroscope', 'sensors'],
['magnetometer', 'sensors'],
['accessibility-events', 'accessibilityEvents'],
['clipboard-read', 'clipboardReadWrite'],
['clipboard-write', 'clipboardReadWrite'],
['payment-handler', 'paymentHandler'],
['persistent-storage', 'durableStorage'],
['idle-detection', 'idleDetection'],
// chrome-specific permissions we have.
['midi-sysex', 'midiSysex'],
]);
/**
* A Browser is created when Puppeteer connects to a Chromium instance, either through
* {@link PuppeteerNode.launch} or {@link Puppeteer.connect}.
*
* @remarks
*
* The Browser class extends from Puppeteer's {@link EventEmitter} class and will
* emit various events which are documented in the {@link BrowserEmittedEvents} enum.
*
* @example
* An example of using a {@link Browser} to create a {@link Page}:
*
* ```ts
* import puppeteer from 'puppeteer';
*
* (async () => {
* const browser = await puppeteer.launch();
* const page = await browser.newPage();
* await page.goto('https://example.com');
* await browser.close();
* })();
* ```
*
* @example
* An example of disconnecting from and reconnecting to a {@link Browser}:
*
* ```ts
* import puppeteer from 'puppeteer';
*
* (async () => {
* const browser = await puppeteer.launch();
* // Store the endpoint to be able to reconnect to Chromium
* const browserWSEndpoint = browser.wsEndpoint();
* // Disconnect puppeteer from Chromium
* browser.disconnect();
*
* // Use the endpoint to reestablish a connection
* const browser2 = await puppeteer.connect({browserWSEndpoint});
* // Close Chromium
* await browser2.close();
* })();
* ```
*
* @public
*/
class Browser extends EventEmitter_js_1.EventEmitter {
/**
* @internal
*/
constructor() {
super();
}
/**
* @internal
*/
_attach() {
throw new Error('Not implemented');
}
/**
* @internal
*/
_detach() {
throw new Error('Not implemented');
}
/**
* @internal
*/
get _targets() {
throw new Error('Not implemented');
}
/**
* The spawned browser process. Returns `null` if the browser instance was created with
* {@link Puppeteer.connect}.
*/
process() {
throw new Error('Not implemented');
}
/**
* @internal
*/
_getIsPageTargetCallback() {
throw new Error('Not implemented');
}
createIncognitoBrowserContext() {
throw new Error('Not implemented');
}
/**
* Returns an array of all open browser contexts. In a newly created browser, this will
* return a single instance of {@link BrowserContext}.
*/
browserContexts() {
throw new Error('Not implemented');
}
/**
* Returns the default browser context. The default browser context cannot be closed.
*/
defaultBrowserContext() {
throw new Error('Not implemented');
}
_disposeContext() {
throw new Error('Not implemented');
}
/**
* The browser websocket endpoint which can be used as an argument to
* {@link Puppeteer.connect}.
*
* @returns The Browser websocket url.
*
* @remarks
*
* The format is `ws://${host}:${port}/devtools/browser/<id>`.
*
* You can find the `webSocketDebuggerUrl` from `http://${host}:${port}/json/version`.
* Learn more about the
* {@link https://chromedevtools.github.io/devtools-protocol | devtools protocol} and
* the {@link
* https://chromedevtools.github.io/devtools-protocol/#how-do-i-access-the-browser-target
* | browser endpoint}.
*/
wsEndpoint() {
throw new Error('Not implemented');
}
/**
* Promise which resolves to a new {@link Page} object. The Page is created in
* a default browser context.
*/
newPage() {
throw new Error('Not implemented');
}
_createPageInContext() {
throw new Error('Not implemented');
}
/**
* All active targets inside the Browser. In case of multiple browser contexts, returns
* an array with all the targets in all browser contexts.
*/
targets() {
throw new Error('Not implemented');
}
/**
* The target associated with the browser.
*/
target() {
throw new Error('Not implemented');
}
waitForTarget() {
throw new Error('Not implemented');
}
/**
* An array of all open pages inside the Browser.
*
* @remarks
*
* In case of multiple browser contexts, returns an array with all the pages in all
* browser contexts. Non-visible pages, such as `"background_page"`, will not be listed
* here. You can find them using {@link Target.page}.
*/
pages() {
throw new Error('Not implemented');
}
/**
* A string representing the browser name and version.
*
* @remarks
*
* For headless Chromium, this is similar to `HeadlessChrome/61.0.3153.0`. For
* non-headless, this is similar to `Chrome/61.0.3153.0`.
*
* The format of browser.version() might change with future releases of Chromium.
*/
version() {
throw new Error('Not implemented');
}
/**
* The browser's original user agent. Pages can override the browser user agent with
* {@link Page.setUserAgent}.
*/
userAgent() {
throw new Error('Not implemented');
}
/**
* Closes Chromium and all of its pages (if any were opened). The {@link Browser} object
* itself is considered to be disposed and cannot be used anymore.
*/
close() {
throw new Error('Not implemented');
}
/**
* Disconnects Puppeteer from the browser, but leaves the Chromium process running.
* After calling `disconnect`, the {@link Browser} object is considered disposed and
* cannot be used anymore.
*/
disconnect() {
throw new Error('Not implemented');
}
/**
* Indicates that the browser is connected.
*/
isConnected() {
throw new Error('Not implemented');
}
}
exports.Browser = Browser;
//# sourceMappingURL=Browser.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"Browser.js","sourceRoot":"","sources":["../../../../src/api/Browser.ts"],"names":[],"mappings":"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"}

View file

@ -1,148 +0,0 @@
/**
* Copyright 2017 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { EventEmitter } from '../common/EventEmitter.js';
import { Page } from './Page.js';
import { Target } from '../common/Target.js';
import type { Permission, Browser } from './Browser.js';
/**
* BrowserContexts provide a way to operate multiple independent browser
* sessions. When a browser is launched, it has a single BrowserContext used by
* default. The method {@link Browser.newPage | Browser.newPage} creates a page
* in the default browser context.
*
* @remarks
*
* The Browser class extends from Puppeteer's {@link EventEmitter} class and
* will emit various events which are documented in the
* {@link BrowserContextEmittedEvents} enum.
*
* If a page opens another page, e.g. with a `window.open` call, the popup will
* belong to the parent page's browser context.
*
* Puppeteer allows creation of "incognito" browser contexts with
* {@link Browser.createIncognitoBrowserContext | Browser.createIncognitoBrowserContext}
* method. "Incognito" browser contexts don't write any browsing data to disk.
*
* @example
*
* ```ts
* // Create a new incognito browser context
* const context = await browser.createIncognitoBrowserContext();
* // Create a new page inside context.
* const page = await context.newPage();
* // ... do stuff with page ...
* await page.goto('https://example.com');
* // Dispose context once it's no longer needed.
* await context.close();
* ```
*
* @public
*/
export declare class BrowserContext extends EventEmitter {
/**
* @internal
*/
constructor();
/**
* An array of all active targets inside the browser context.
*/
targets(): Target[];
/**
* This searches for a target in this specific browser context.
*
* @example
* An example of finding a target for a page opened via `window.open`:
*
* ```ts
* await page.evaluate(() => window.open('https://www.example.com/'));
* const newWindowTarget = await browserContext.waitForTarget(
* target => target.url() === 'https://www.example.com/'
* );
* ```
*
* @param predicate - A function to be run for every target
* @param options - An object of options. Accepts a timeout,
* which is the maximum wait time in milliseconds.
* Pass `0` to disable the timeout. Defaults to 30 seconds.
* @returns Promise which resolves to the first target found
* that matches the `predicate` function.
*/
waitForTarget(predicate: (x: Target) => boolean | Promise<boolean>, options?: {
timeout?: number;
}): Promise<Target>;
/**
* An array of all pages inside the browser context.
*
* @returns Promise which resolves to an array of all open pages.
* Non visible pages, such as `"background_page"`, will not be listed here.
* You can find them using {@link Target.page | the target page}.
*/
pages(): Promise<Page[]>;
/**
* Returns whether BrowserContext is incognito.
* The default browser context is the only non-incognito browser context.
*
* @remarks
* The default browser context cannot be closed.
*/
isIncognito(): boolean;
/**
* @example
*
* ```ts
* const context = browser.defaultBrowserContext();
* await context.overridePermissions('https://html5demos.com', [
* 'geolocation',
* ]);
* ```
*
* @param origin - The origin to grant permissions to, e.g. "https://example.com".
* @param permissions - An array of permissions to grant.
* All permissions that are not listed here will be automatically denied.
*/
overridePermissions(origin: string, permissions: Permission[]): Promise<void>;
/**
* Clears all permission overrides for the browser context.
*
* @example
*
* ```ts
* const context = browser.defaultBrowserContext();
* context.overridePermissions('https://example.com', ['clipboard-read']);
* // do stuff ..
* context.clearPermissionOverrides();
* ```
*/
clearPermissionOverrides(): Promise<void>;
/**
* Creates a new page in the browser context.
*/
newPage(): Promise<Page>;
/**
* The browser this browser context belongs to.
*/
browser(): Browser;
/**
* Closes the browser context. All the targets that belong to the browser context
* will be closed.
*
* @remarks
* Only incognito browser contexts can be closed.
*/
close(): Promise<void>;
get id(): string | undefined;
}
//# sourceMappingURL=BrowserContext.d.ts.map

View file

@ -1 +0,0 @@
{"version":3,"file":"BrowserContext.d.ts","sourceRoot":"","sources":["../../../../src/api/BrowserContext.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAC,YAAY,EAAC,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAC;AAC/B,OAAO,EAAC,MAAM,EAAC,MAAM,qBAAqB,CAAC;AAC3C,OAAO,KAAK,EAAC,UAAU,EAAE,OAAO,EAAC,MAAM,cAAc,CAAC;AAEtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,qBAAa,cAAe,SAAQ,YAAY;IAC9C;;OAEG;;IAKH;;OAEG;IACH,OAAO,IAAI,MAAM,EAAE;IAInB;;;;;;;;;;;;;;;;;;;OAmBG;IACH,aAAa,CACX,SAAS,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,EACpD,OAAO,CAAC,EAAE;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAC,GAC3B,OAAO,CAAC,MAAM,CAAC;IAKlB;;;;;;OAMG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;IAIxB;;;;;;OAMG;IACH,WAAW,IAAI,OAAO;IAItB;;;;;;;;;;;;;OAaG;IACH,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAK7E;;;;;;;;;;;OAWG;IACH,wBAAwB,IAAI,OAAO,CAAC,IAAI,CAAC;IAIzC;;OAEG;IACH,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAIxB;;OAEG;IACH,OAAO,IAAI,OAAO;IAIlB;;;;;;OAMG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAItB,IAAI,EAAE,IAAI,MAAM,GAAG,SAAS,CAE3B;CACF"}

View file

@ -1,135 +0,0 @@
"use strict";
/**
* Copyright 2017 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.BrowserContext = void 0;
const EventEmitter_js_1 = require("../common/EventEmitter.js");
/**
* BrowserContexts provide a way to operate multiple independent browser
* sessions. When a browser is launched, it has a single BrowserContext used by
* default. The method {@link Browser.newPage | Browser.newPage} creates a page
* in the default browser context.
*
* @remarks
*
* The Browser class extends from Puppeteer's {@link EventEmitter} class and
* will emit various events which are documented in the
* {@link BrowserContextEmittedEvents} enum.
*
* If a page opens another page, e.g. with a `window.open` call, the popup will
* belong to the parent page's browser context.
*
* Puppeteer allows creation of "incognito" browser contexts with
* {@link Browser.createIncognitoBrowserContext | Browser.createIncognitoBrowserContext}
* method. "Incognito" browser contexts don't write any browsing data to disk.
*
* @example
*
* ```ts
* // Create a new incognito browser context
* const context = await browser.createIncognitoBrowserContext();
* // Create a new page inside context.
* const page = await context.newPage();
* // ... do stuff with page ...
* await page.goto('https://example.com');
* // Dispose context once it's no longer needed.
* await context.close();
* ```
*
* @public
*/
class BrowserContext extends EventEmitter_js_1.EventEmitter {
/**
* @internal
*/
constructor() {
super();
}
/**
* An array of all active targets inside the browser context.
*/
targets() {
throw new Error('Not implemented');
}
waitForTarget() {
throw new Error('Not implemented');
}
/**
* An array of all pages inside the browser context.
*
* @returns Promise which resolves to an array of all open pages.
* Non visible pages, such as `"background_page"`, will not be listed here.
* You can find them using {@link Target.page | the target page}.
*/
pages() {
throw new Error('Not implemented');
}
/**
* Returns whether BrowserContext is incognito.
* The default browser context is the only non-incognito browser context.
*
* @remarks
* The default browser context cannot be closed.
*/
isIncognito() {
throw new Error('Not implemented');
}
overridePermissions() {
throw new Error('Not implemented');
}
/**
* Clears all permission overrides for the browser context.
*
* @example
*
* ```ts
* const context = browser.defaultBrowserContext();
* context.overridePermissions('https://example.com', ['clipboard-read']);
* // do stuff ..
* context.clearPermissionOverrides();
* ```
*/
clearPermissionOverrides() {
throw new Error('Not implemented');
}
/**
* Creates a new page in the browser context.
*/
newPage() {
throw new Error('Not implemented');
}
/**
* The browser this browser context belongs to.
*/
browser() {
throw new Error('Not implemented');
}
/**
* Closes the browser context. All the targets that belong to the browser context
* will be closed.
*
* @remarks
* Only incognito browser contexts can be closed.
*/
close() {
throw new Error('Not implemented');
}
get id() {
return undefined;
}
}
exports.BrowserContext = BrowserContext;
//# sourceMappingURL=BrowserContext.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"BrowserContext.js","sourceRoot":"","sources":["../../../../src/api/BrowserContext.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,+DAAuD;AAKvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,MAAa,cAAe,SAAQ,8BAAY;IAC9C;;OAEG;IACH;QACE,KAAK,EAAE,CAAC;IACV,CAAC;IAED;;OAEG;IACH,OAAO;QACL,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;IA0BD,aAAa;QACX,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;IAED;;;;;;OAMG;IACH,KAAK;QACH,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;IAED;;;;;;OAMG;IACH,WAAW;QACT,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;IAiBD,mBAAmB;QACjB,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;IAED;;;;;;;;;;;OAWG;IACH,wBAAwB;QACtB,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;IAED;;OAEG;IACH,OAAO;QACL,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;IAED;;OAEG;IACH,OAAO;QACL,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;IAED;;;;;;OAMG;IACH,KAAK;QACH,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;IAED,IAAI,EAAE;QACJ,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AAhID,wCAgIC"}

File diff suppressed because one or more lines are too long

View file

@ -1,536 +0,0 @@
"use strict";
/**
* Copyright 2017 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _Page_handlerMap;
Object.defineProperty(exports, "__esModule", { value: true });
exports.unitToPixels = exports.supportedMetrics = exports.Page = void 0;
const EventEmitter_js_1 = require("../common/EventEmitter.js");
/**
* Page provides methods to interact with a single tab or
* {@link https://developer.chrome.com/extensions/background_pages | extension background page}
* in Chromium.
*
* :::note
*
* One Browser instance might have multiple Page instances.
*
* :::
*
* @example
* This example creates a page, navigates it to a URL, and then saves a screenshot:
*
* ```ts
* import puppeteer from 'puppeteer';
*
* (async () => {
* const browser = await puppeteer.launch();
* const page = await browser.newPage();
* await page.goto('https://example.com');
* await page.screenshot({path: 'screenshot.png'});
* await browser.close();
* })();
* ```
*
* The Page class extends from Puppeteer's {@link EventEmitter} class and will
* emit various events which are documented in the {@link PageEmittedEvents} enum.
*
* @example
* This example logs a message for a single page `load` event:
*
* ```ts
* page.once('load', () => console.log('Page loaded!'));
* ```
*
* To unsubscribe from events use the {@link Page.off} method:
*
* ```ts
* function logRequest(interceptedRequest) {
* console.log('A request was made:', interceptedRequest.url());
* }
* page.on('request', logRequest);
* // Sometime later...
* page.off('request', logRequest);
* ```
*
* @public
*/
class Page extends EventEmitter_js_1.EventEmitter {
/**
* @internal
*/
constructor() {
super();
_Page_handlerMap.set(this, new WeakMap());
}
/**
* @returns `true` if drag events are being intercepted, `false` otherwise.
*/
isDragInterceptionEnabled() {
throw new Error('Not implemented');
}
/**
* @returns `true` if the page has JavaScript enabled, `false` otherwise.
*/
isJavaScriptEnabled() {
throw new Error('Not implemented');
}
/**
* Listen to page events.
*
* :::note
*
* This method exists to define event typings and handle proper wireup of
* cooperative request interception. Actual event listening and dispatching is
* delegated to {@link EventEmitter}.
*
* :::
*/
on(eventName, handler) {
if (eventName === 'request') {
const wrap = __classPrivateFieldGet(this, _Page_handlerMap, "f").get(handler) ||
((event) => {
event.enqueueInterceptAction(() => {
return handler(event);
});
});
__classPrivateFieldGet(this, _Page_handlerMap, "f").set(handler, wrap);
return super.on(eventName, wrap);
}
return super.on(eventName, handler);
}
once(eventName, handler) {
// Note: this method only exists to define the types; we delegate the impl
// to EventEmitter.
return super.once(eventName, handler);
}
off(eventName, handler) {
if (eventName === 'request') {
handler = __classPrivateFieldGet(this, _Page_handlerMap, "f").get(handler) || handler;
}
return super.off(eventName, handler);
}
waitForFileChooser() {
throw new Error('Not implemented');
}
async setGeolocation() {
throw new Error('Not implemented');
}
/**
* @returns A target this page was created from.
*/
target() {
throw new Error('Not implemented');
}
/**
* Get the browser the page belongs to.
*/
browser() {
throw new Error('Not implemented');
}
/**
* Get the browser context that the page belongs to.
*/
browserContext() {
throw new Error('Not implemented');
}
/**
* @returns The page's main frame.
*
* @remarks
* Page is guaranteed to have a main frame which persists during navigations.
*/
mainFrame() {
throw new Error('Not implemented');
}
get keyboard() {
throw new Error('Not implemented');
}
get touchscreen() {
throw new Error('Not implemented');
}
get coverage() {
throw new Error('Not implemented');
}
get tracing() {
throw new Error('Not implemented');
}
get accessibility() {
throw new Error('Not implemented');
}
/**
* @returns An array of all frames attached to the page.
*/
frames() {
throw new Error('Not implemented');
}
/**
* @returns all of the dedicated {@link
* https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API |
* WebWorkers} associated with the page.
*
* @remarks
* This does not contain ServiceWorkers
*/
workers() {
throw new Error('Not implemented');
}
async setRequestInterception() {
throw new Error('Not implemented');
}
async setDragInterception() {
throw new Error('Not implemented');
}
setOfflineMode() {
throw new Error('Not implemented');
}
emulateNetworkConditions() {
throw new Error('Not implemented');
}
setDefaultNavigationTimeout() {
throw new Error('Not implemented');
}
setDefaultTimeout() {
throw new Error('Not implemented');
}
/**
* @returns Maximum time in milliseconds.
*/
getDefaultTimeout() {
throw new Error('Not implemented');
}
async $() {
throw new Error('Not implemented');
}
async $$() {
throw new Error('Not implemented');
}
async evaluateHandle() {
throw new Error('Not implemented');
}
async queryObjects() {
throw new Error('Not implemented');
}
async $eval() {
throw new Error('Not implemented');
}
async $$eval() {
throw new Error('Not implemented');
}
async $x() {
throw new Error('Not implemented');
}
async cookies() {
throw new Error('Not implemented');
}
async deleteCookie() {
throw new Error('Not implemented');
}
async setCookie() {
throw new Error('Not implemented');
}
async addScriptTag() {
throw new Error('Not implemented');
}
async addStyleTag() {
throw new Error('Not implemented');
}
async exposeFunction() {
throw new Error('Not implemented');
}
async authenticate() {
throw new Error('Not implemented');
}
async setExtraHTTPHeaders() {
throw new Error('Not implemented');
}
async setUserAgent() {
throw new Error('Not implemented');
}
/**
* @returns Object containing metrics as key/value pairs.
*
* - `Timestamp` : The timestamp when the metrics sample was taken.
*
* - `Documents` : Number of documents in the page.
*
* - `Frames` : Number of frames in the page.
*
* - `JSEventListeners` : Number of events in the page.
*
* - `Nodes` : Number of DOM nodes in the page.
*
* - `LayoutCount` : Total number of full or partial page layout.
*
* - `RecalcStyleCount` : Total number of page style recalculations.
*
* - `LayoutDuration` : Combined durations of all page layouts.
*
* - `RecalcStyleDuration` : Combined duration of all page style
* recalculations.
*
* - `ScriptDuration` : Combined duration of JavaScript execution.
*
* - `TaskDuration` : Combined duration of all tasks performed by the browser.
*
* - `JSHeapUsedSize` : Used JavaScript heap size.
*
* - `JSHeapTotalSize` : Total JavaScript heap size.
*
* @remarks
* All timestamps are in monotonic time: monotonically increasing time
* in seconds since an arbitrary point in the past.
*/
async metrics() {
throw new Error('Not implemented');
}
/**
*
* @returns
* @remarks Shortcut for
* {@link Frame.url | page.mainFrame().url()}.
*/
url() {
throw new Error('Not implemented');
}
async content() {
throw new Error('Not implemented');
}
async setContent() {
throw new Error('Not implemented');
}
async goto() {
throw new Error('Not implemented');
}
async reload() {
throw new Error('Not implemented');
}
async waitForNavigation() {
throw new Error('Not implemented');
}
async waitForRequest() {
throw new Error('Not implemented');
}
async waitForResponse() {
throw new Error('Not implemented');
}
async waitForNetworkIdle() {
throw new Error('Not implemented');
}
async waitForFrame() {
throw new Error('Not implemented');
}
async goBack() {
throw new Error('Not implemented');
}
async goForward() {
throw new Error('Not implemented');
}
/**
* Brings page to front (activates tab).
*/
async bringToFront() {
throw new Error('Not implemented');
}
/**
* Emulates a given device's metrics and user agent.
*
* To aid emulation, Puppeteer provides a list of known devices that can be
* via {@link KnownDevices}.
*
* @remarks
* This method is a shortcut for calling two methods:
* {@link Page.setUserAgent} and {@link Page.setViewport}.
*
* @remarks
* This method will resize the page. A lot of websites don't expect phones to
* change size, so you should emulate before navigating to the page.
*
* @example
*
* ```ts
* import {KnownDevices} from 'puppeteer';
* const iPhone = KnownDevices['iPhone 6'];
*
* (async () => {
* const browser = await puppeteer.launch();
* const page = await browser.newPage();
* await page.emulate(iPhone);
* await page.goto('https://www.google.com');
* // other actions...
* await browser.close();
* })();
* ```
*/
async emulate(device) {
await Promise.all([
this.setUserAgent(device.userAgent),
this.setViewport(device.viewport),
]);
}
async setJavaScriptEnabled() {
throw new Error('Not implemented');
}
async setBypassCSP() {
throw new Error('Not implemented');
}
async emulateMediaType() {
throw new Error('Not implemented');
}
async emulateCPUThrottling() {
throw new Error('Not implemented');
}
async emulateMediaFeatures() {
throw new Error('Not implemented');
}
async emulateTimezone() {
throw new Error('Not implemented');
}
async emulateIdleState() {
throw new Error('Not implemented');
}
async emulateVisionDeficiency() {
throw new Error('Not implemented');
}
async setViewport() {
throw new Error('Not implemented');
}
/**
* @returns
*
* - `width`: page's width in pixels
*
* - `height`: page's height in pixels
*
* - `deviceScaleFactor`: Specify device scale factor (can be though of as
* dpr). Defaults to `1`.
*
* - `isMobile`: Whether the meta viewport tag is taken into account. Defaults
* to `false`.
*
* - `hasTouch`: Specifies if viewport supports touch events. Defaults to
* `false`.
*
* - `isLandScape`: Specifies if viewport is in landscape mode. Defaults to
* `false`.
*/
viewport() {
throw new Error('Not implemented');
}
async evaluate() {
throw new Error('Not implemented');
}
async evaluateOnNewDocument() {
throw new Error('Not implemented');
}
async setCacheEnabled() {
throw new Error('Not implemented');
}
async screenshot() {
throw new Error('Not implemented');
}
async createPDFStream() {
throw new Error('Not implemented');
}
async pdf() {
throw new Error('Not implemented');
}
/**
* @returns The page's title
* @remarks
* Shortcut for {@link Frame.title | page.mainFrame().title()}.
*/
async title() {
throw new Error('Not implemented');
}
async close() {
throw new Error('Not implemented');
}
/**
* Indicates that the page has been closed.
* @returns
*/
isClosed() {
throw new Error('Not implemented');
}
get mouse() {
throw new Error('Not implemented');
}
click() {
throw new Error('Not implemented');
}
focus() {
throw new Error('Not implemented');
}
hover() {
throw new Error('Not implemented');
}
select() {
throw new Error('Not implemented');
}
tap() {
throw new Error('Not implemented');
}
type() {
throw new Error('Not implemented');
}
waitForTimeout() {
throw new Error('Not implemented');
}
async waitForSelector() {
throw new Error('Not implemented');
}
waitForXPath() {
throw new Error('Not implemented');
}
waitForFunction() {
throw new Error('Not implemented');
}
}
exports.Page = Page;
_Page_handlerMap = new WeakMap();
/**
* @internal
*/
exports.supportedMetrics = new Set([
'Timestamp',
'Documents',
'Frames',
'JSEventListeners',
'Nodes',
'LayoutCount',
'RecalcStyleCount',
'LayoutDuration',
'RecalcStyleDuration',
'ScriptDuration',
'TaskDuration',
'JSHeapUsedSize',
'JSHeapTotalSize',
]);
/**
* @internal
*/
exports.unitToPixels = {
px: 1,
in: 96,
cm: 37.8,
mm: 3.78,
};
//# sourceMappingURL=Page.js.map

File diff suppressed because one or more lines are too long

View file

@ -1,19 +0,0 @@
/**
* Copyright 2022 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export * from './Browser.js';
export * from './BrowserContext.js';
export * from './Page.js';
//# sourceMappingURL=api.d.ts.map

View file

@ -1 +0,0 @@
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../../src/api/api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,WAAW,CAAC"}

View file

@ -1,35 +0,0 @@
"use strict";
/**
* Copyright 2022 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./Browser.js"), exports);
__exportStar(require("./BrowserContext.js"), exports);
__exportStar(require("./Page.js"), exports);
//# sourceMappingURL=api.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../../../src/api/api.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;AAEH,+CAA6B;AAC7B,sDAAoC;AACpC,4CAA0B"}

View file

@ -1,176 +0,0 @@
/**
* Copyright 2018 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { CDPSession } from './Connection.js';
import { ElementHandle } from './ElementHandle.js';
/**
* Represents a Node and the properties of it that are relevant to Accessibility.
* @public
*/
export interface SerializedAXNode {
/**
* The {@link https://www.w3.org/TR/wai-aria/#usage_intro | role} of the node.
*/
role: string;
/**
* A human readable name for the node.
*/
name?: string;
/**
* The current value of the node.
*/
value?: string | number;
/**
* An additional human readable description of the node.
*/
description?: string;
/**
* Any keyboard shortcuts associated with this node.
*/
keyshortcuts?: string;
/**
* A human readable alternative to the role.
*/
roledescription?: string;
/**
* A description of the current value.
*/
valuetext?: string;
disabled?: boolean;
expanded?: boolean;
focused?: boolean;
modal?: boolean;
multiline?: boolean;
/**
* Whether more than one child can be selected.
*/
multiselectable?: boolean;
readonly?: boolean;
required?: boolean;
selected?: boolean;
/**
* Whether the checkbox is checked, or in a
* {@link https://www.w3.org/TR/wai-aria-practices/examples/checkbox/checkbox-2/checkbox-2.html | mixed state}.
*/
checked?: boolean | 'mixed';
/**
* Whether the node is checked or in a mixed state.
*/
pressed?: boolean | 'mixed';
/**
* The level of a heading.
*/
level?: number;
valuemin?: number;
valuemax?: number;
autocomplete?: string;
haspopup?: string;
/**
* Whether and in what way this node's value is invalid.
*/
invalid?: string;
orientation?: string;
/**
* Children of this node, if there are any.
*/
children?: SerializedAXNode[];
}
/**
* @public
*/
export interface SnapshotOptions {
/**
* Prune uninteresting nodes from the tree.
* @defaultValue true
*/
interestingOnly?: boolean;
/**
* Root node to get the accessibility tree for
* @defaultValue The root node of the entire page.
*/
root?: ElementHandle<Node>;
}
/**
* The Accessibility class provides methods for inspecting Chromium's
* accessibility tree. The accessibility tree is used by assistive technology
* such as {@link https://en.wikipedia.org/wiki/Screen_reader | screen readers} or
* {@link https://en.wikipedia.org/wiki/Switch_access | switches}.
*
* @remarks
*
* Accessibility is a very platform-specific thing. On different platforms,
* there are different screen readers that might have wildly different output.
*
* Blink - Chrome's rendering engine - has a concept of "accessibility tree",
* which is then translated into different platform-specific APIs. Accessibility
* namespace gives users access to the Blink Accessibility Tree.
*
* Most of the accessibility tree gets filtered out when converting from Blink
* AX Tree to Platform-specific AX-Tree or by assistive technologies themselves.
* By default, Puppeteer tries to approximate this filtering, exposing only
* the "interesting" nodes of the tree.
*
* @public
*/
export declare class Accessibility {
#private;
/**
* @internal
*/
constructor(client: CDPSession);
/**
* Captures the current state of the accessibility tree.
* The returned object represents the root accessible node of the page.
*
* @remarks
*
* **NOTE** The Chromium accessibility tree contains nodes that go unused on
* most platforms and by most screen readers. Puppeteer will discard them as
* well for an easier to process tree, unless `interestingOnly` is set to
* `false`.
*
* @example
* An example of dumping the entire accessibility tree:
*
* ```ts
* const snapshot = await page.accessibility.snapshot();
* console.log(snapshot);
* ```
*
* @example
* An example of logging the focused node's name:
*
* ```ts
* const snapshot = await page.accessibility.snapshot();
* const node = findFocusedNode(snapshot);
* console.log(node && node.name);
*
* function findFocusedNode(node) {
* if (node.focused) return node;
* for (const child of node.children || []) {
* const foundNode = findFocusedNode(child);
* return foundNode;
* }
* return null;
* }
* ```
*
* @returns An AXNode object representing the snapshot.
*/
snapshot(options?: SnapshotOptions): Promise<SerializedAXNode | null>;
private serializeTree;
private collectInterestingNodes;
}
//# sourceMappingURL=Accessibility.d.ts.map

View file

@ -1 +0,0 @@
{"version":3,"file":"Accessibility.d.ts","sourceRoot":"","sources":["../../../../src/common/Accessibility.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAC,UAAU,EAAC,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAC;AAEjD;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;IAC5B;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;IAC5B;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,QAAQ,CAAC,EAAE,gBAAgB,EAAE,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;OAGG;IACH,IAAI,CAAC,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,aAAa;;IAGxB;;OAEG;gBACS,MAAM,EAAE,UAAU;IAI9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAsCG;IACU,QAAQ,CACnB,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAgCnC,OAAO,CAAC,aAAa;IAoBrB,OAAO,CAAC,uBAAuB;CAgBhC"}

View file

@ -1,428 +0,0 @@
"use strict";
/**
* Copyright 2018 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _Accessibility_client, _AXNode_instances, _AXNode_richlyEditable, _AXNode_editable, _AXNode_focusable, _AXNode_hidden, _AXNode_name, _AXNode_role, _AXNode_ignored, _AXNode_cachedHasFocusableChild, _AXNode_isPlainTextField, _AXNode_isTextOnlyObject, _AXNode_hasFocusableChild;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Accessibility = void 0;
/**
* The Accessibility class provides methods for inspecting Chromium's
* accessibility tree. The accessibility tree is used by assistive technology
* such as {@link https://en.wikipedia.org/wiki/Screen_reader | screen readers} or
* {@link https://en.wikipedia.org/wiki/Switch_access | switches}.
*
* @remarks
*
* Accessibility is a very platform-specific thing. On different platforms,
* there are different screen readers that might have wildly different output.
*
* Blink - Chrome's rendering engine - has a concept of "accessibility tree",
* which is then translated into different platform-specific APIs. Accessibility
* namespace gives users access to the Blink Accessibility Tree.
*
* Most of the accessibility tree gets filtered out when converting from Blink
* AX Tree to Platform-specific AX-Tree or by assistive technologies themselves.
* By default, Puppeteer tries to approximate this filtering, exposing only
* the "interesting" nodes of the tree.
*
* @public
*/
class Accessibility {
/**
* @internal
*/
constructor(client) {
_Accessibility_client.set(this, void 0);
__classPrivateFieldSet(this, _Accessibility_client, client, "f");
}
/**
* Captures the current state of the accessibility tree.
* The returned object represents the root accessible node of the page.
*
* @remarks
*
* **NOTE** The Chromium accessibility tree contains nodes that go unused on
* most platforms and by most screen readers. Puppeteer will discard them as
* well for an easier to process tree, unless `interestingOnly` is set to
* `false`.
*
* @example
* An example of dumping the entire accessibility tree:
*
* ```ts
* const snapshot = await page.accessibility.snapshot();
* console.log(snapshot);
* ```
*
* @example
* An example of logging the focused node's name:
*
* ```ts
* const snapshot = await page.accessibility.snapshot();
* const node = findFocusedNode(snapshot);
* console.log(node && node.name);
*
* function findFocusedNode(node) {
* if (node.focused) return node;
* for (const child of node.children || []) {
* const foundNode = findFocusedNode(child);
* return foundNode;
* }
* return null;
* }
* ```
*
* @returns An AXNode object representing the snapshot.
*/
async snapshot(options = {}) {
var _a, _b;
const { interestingOnly = true, root = null } = options;
const { nodes } = await __classPrivateFieldGet(this, _Accessibility_client, "f").send('Accessibility.getFullAXTree');
let backendNodeId;
if (root) {
const { node } = await __classPrivateFieldGet(this, _Accessibility_client, "f").send('DOM.describeNode', {
objectId: root.remoteObject().objectId,
});
backendNodeId = node.backendNodeId;
}
const defaultRoot = AXNode.createTree(nodes);
let needle = defaultRoot;
if (backendNodeId) {
needle = defaultRoot.find(node => {
return node.payload.backendDOMNodeId === backendNodeId;
});
if (!needle) {
return null;
}
}
if (!interestingOnly) {
return (_a = this.serializeTree(needle)[0]) !== null && _a !== void 0 ? _a : null;
}
const interestingNodes = new Set();
this.collectInterestingNodes(interestingNodes, defaultRoot, false);
if (!interestingNodes.has(needle)) {
return null;
}
return (_b = this.serializeTree(needle, interestingNodes)[0]) !== null && _b !== void 0 ? _b : null;
}
serializeTree(node, interestingNodes) {
const children = [];
for (const child of node.children) {
children.push(...this.serializeTree(child, interestingNodes));
}
if (interestingNodes && !interestingNodes.has(node)) {
return children;
}
const serializedNode = node.serialize();
if (children.length) {
serializedNode.children = children;
}
return [serializedNode];
}
collectInterestingNodes(collection, node, insideControl) {
if (node.isInteresting(insideControl)) {
collection.add(node);
}
if (node.isLeafNode()) {
return;
}
insideControl = insideControl || node.isControl();
for (const child of node.children) {
this.collectInterestingNodes(collection, child, insideControl);
}
}
}
exports.Accessibility = Accessibility;
_Accessibility_client = new WeakMap();
class AXNode {
constructor(payload) {
_AXNode_instances.add(this);
this.children = [];
_AXNode_richlyEditable.set(this, false);
_AXNode_editable.set(this, false);
_AXNode_focusable.set(this, false);
_AXNode_hidden.set(this, false);
_AXNode_name.set(this, void 0);
_AXNode_role.set(this, void 0);
_AXNode_ignored.set(this, void 0);
_AXNode_cachedHasFocusableChild.set(this, void 0);
this.payload = payload;
__classPrivateFieldSet(this, _AXNode_name, this.payload.name ? this.payload.name.value : '', "f");
__classPrivateFieldSet(this, _AXNode_role, this.payload.role ? this.payload.role.value : 'Unknown', "f");
__classPrivateFieldSet(this, _AXNode_ignored, this.payload.ignored, "f");
for (const property of this.payload.properties || []) {
if (property.name === 'editable') {
__classPrivateFieldSet(this, _AXNode_richlyEditable, property.value.value === 'richtext', "f");
__classPrivateFieldSet(this, _AXNode_editable, true, "f");
}
if (property.name === 'focusable') {
__classPrivateFieldSet(this, _AXNode_focusable, property.value.value, "f");
}
if (property.name === 'hidden') {
__classPrivateFieldSet(this, _AXNode_hidden, property.value.value, "f");
}
}
}
find(predicate) {
if (predicate(this)) {
return this;
}
for (const child of this.children) {
const result = child.find(predicate);
if (result) {
return result;
}
}
return null;
}
isLeafNode() {
if (!this.children.length) {
return true;
}
// These types of objects may have children that we use as internal
// implementation details, but we want to expose them as leaves to platform
// accessibility APIs because screen readers might be confused if they find
// any children.
if (__classPrivateFieldGet(this, _AXNode_instances, "m", _AXNode_isPlainTextField).call(this) || __classPrivateFieldGet(this, _AXNode_instances, "m", _AXNode_isTextOnlyObject).call(this)) {
return true;
}
// Roles whose children are only presentational according to the ARIA and
// HTML5 Specs should be hidden from screen readers.
// (Note that whilst ARIA buttons can have only presentational children, HTML5
// buttons are allowed to have content.)
switch (__classPrivateFieldGet(this, _AXNode_role, "f")) {
case 'doc-cover':
case 'graphics-symbol':
case 'img':
case 'Meter':
case 'scrollbar':
case 'slider':
case 'separator':
case 'progressbar':
return true;
default:
break;
}
// Here and below: Android heuristics
if (__classPrivateFieldGet(this, _AXNode_instances, "m", _AXNode_hasFocusableChild).call(this)) {
return false;
}
if (__classPrivateFieldGet(this, _AXNode_focusable, "f") && __classPrivateFieldGet(this, _AXNode_name, "f")) {
return true;
}
if (__classPrivateFieldGet(this, _AXNode_role, "f") === 'heading' && __classPrivateFieldGet(this, _AXNode_name, "f")) {
return true;
}
return false;
}
isControl() {
switch (__classPrivateFieldGet(this, _AXNode_role, "f")) {
case 'button':
case 'checkbox':
case 'ColorWell':
case 'combobox':
case 'DisclosureTriangle':
case 'listbox':
case 'menu':
case 'menubar':
case 'menuitem':
case 'menuitemcheckbox':
case 'menuitemradio':
case 'radio':
case 'scrollbar':
case 'searchbox':
case 'slider':
case 'spinbutton':
case 'switch':
case 'tab':
case 'textbox':
case 'tree':
case 'treeitem':
return true;
default:
return false;
}
}
isInteresting(insideControl) {
const role = __classPrivateFieldGet(this, _AXNode_role, "f");
if (role === 'Ignored' || __classPrivateFieldGet(this, _AXNode_hidden, "f") || __classPrivateFieldGet(this, _AXNode_ignored, "f")) {
return false;
}
if (__classPrivateFieldGet(this, _AXNode_focusable, "f") || __classPrivateFieldGet(this, _AXNode_richlyEditable, "f")) {
return true;
}
// If it's not focusable but has a control role, then it's interesting.
if (this.isControl()) {
return true;
}
// A non focusable child of a control is not interesting
if (insideControl) {
return false;
}
return this.isLeafNode() && !!__classPrivateFieldGet(this, _AXNode_name, "f");
}
serialize() {
const properties = new Map();
for (const property of this.payload.properties || []) {
properties.set(property.name.toLowerCase(), property.value.value);
}
if (this.payload.name) {
properties.set('name', this.payload.name.value);
}
if (this.payload.value) {
properties.set('value', this.payload.value.value);
}
if (this.payload.description) {
properties.set('description', this.payload.description.value);
}
const node = {
role: __classPrivateFieldGet(this, _AXNode_role, "f"),
};
const userStringProperties = [
'name',
'value',
'description',
'keyshortcuts',
'roledescription',
'valuetext',
];
const getUserStringPropertyValue = (key) => {
return properties.get(key);
};
for (const userStringProperty of userStringProperties) {
if (!properties.has(userStringProperty)) {
continue;
}
node[userStringProperty] = getUserStringPropertyValue(userStringProperty);
}
const booleanProperties = [
'disabled',
'expanded',
'focused',
'modal',
'multiline',
'multiselectable',
'readonly',
'required',
'selected',
];
const getBooleanPropertyValue = (key) => {
return properties.get(key);
};
for (const booleanProperty of booleanProperties) {
// RootWebArea's treat focus differently than other nodes. They report whether
// their frame has focus, not whether focus is specifically on the root
// node.
if (booleanProperty === 'focused' && __classPrivateFieldGet(this, _AXNode_role, "f") === 'RootWebArea') {
continue;
}
const value = getBooleanPropertyValue(booleanProperty);
if (!value) {
continue;
}
node[booleanProperty] = getBooleanPropertyValue(booleanProperty);
}
const tristateProperties = ['checked', 'pressed'];
for (const tristateProperty of tristateProperties) {
if (!properties.has(tristateProperty)) {
continue;
}
const value = properties.get(tristateProperty);
node[tristateProperty] =
value === 'mixed' ? 'mixed' : value === 'true' ? true : false;
}
const numericalProperties = [
'level',
'valuemax',
'valuemin',
];
const getNumericalPropertyValue = (key) => {
return properties.get(key);
};
for (const numericalProperty of numericalProperties) {
if (!properties.has(numericalProperty)) {
continue;
}
node[numericalProperty] = getNumericalPropertyValue(numericalProperty);
}
const tokenProperties = [
'autocomplete',
'haspopup',
'invalid',
'orientation',
];
const getTokenPropertyValue = (key) => {
return properties.get(key);
};
for (const tokenProperty of tokenProperties) {
const value = getTokenPropertyValue(tokenProperty);
if (!value || value === 'false') {
continue;
}
node[tokenProperty] = getTokenPropertyValue(tokenProperty);
}
return node;
}
static createTree(payloads) {
const nodeById = new Map();
for (const payload of payloads) {
nodeById.set(payload.nodeId, new AXNode(payload));
}
for (const node of nodeById.values()) {
for (const childId of node.payload.childIds || []) {
const child = nodeById.get(childId);
if (child) {
node.children.push(child);
}
}
}
return nodeById.values().next().value;
}
}
_AXNode_richlyEditable = new WeakMap(), _AXNode_editable = new WeakMap(), _AXNode_focusable = new WeakMap(), _AXNode_hidden = new WeakMap(), _AXNode_name = new WeakMap(), _AXNode_role = new WeakMap(), _AXNode_ignored = new WeakMap(), _AXNode_cachedHasFocusableChild = new WeakMap(), _AXNode_instances = new WeakSet(), _AXNode_isPlainTextField = function _AXNode_isPlainTextField() {
if (__classPrivateFieldGet(this, _AXNode_richlyEditable, "f")) {
return false;
}
if (__classPrivateFieldGet(this, _AXNode_editable, "f")) {
return true;
}
return __classPrivateFieldGet(this, _AXNode_role, "f") === 'textbox' || __classPrivateFieldGet(this, _AXNode_role, "f") === 'searchbox';
}, _AXNode_isTextOnlyObject = function _AXNode_isTextOnlyObject() {
const role = __classPrivateFieldGet(this, _AXNode_role, "f");
return role === 'LineBreak' || role === 'text' || role === 'InlineTextBox';
}, _AXNode_hasFocusableChild = function _AXNode_hasFocusableChild() {
if (__classPrivateFieldGet(this, _AXNode_cachedHasFocusableChild, "f") === undefined) {
__classPrivateFieldSet(this, _AXNode_cachedHasFocusableChild, false, "f");
for (const child of this.children) {
if (__classPrivateFieldGet(child, _AXNode_focusable, "f") || __classPrivateFieldGet(child, _AXNode_instances, "m", _AXNode_hasFocusableChild).call(child)) {
__classPrivateFieldSet(this, _AXNode_cachedHasFocusableChild, true, "f");
break;
}
}
}
return __classPrivateFieldGet(this, _AXNode_cachedHasFocusableChild, "f");
};
//# sourceMappingURL=Accessibility.js.map

View file

@ -1,21 +0,0 @@
/**
* Copyright 2020 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import type { PuppeteerQueryHandler } from './QueryHandler.js';
/**
* @internal
*/
export declare const ariaHandler: PuppeteerQueryHandler;
//# sourceMappingURL=AriaQueryHandler.d.ts.map

View file

@ -1 +0,0 @@
{"version":3,"file":"AriaQueryHandler.d.ts","sourceRoot":"","sources":["../../../../src/common/AriaQueryHandler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AASH,OAAO,KAAK,EAAC,qBAAqB,EAAC,MAAM,mBAAmB,CAAC;AA8J7D;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,qBAIzB,CAAC"}

View file

@ -1,126 +0,0 @@
"use strict";
/**
* Copyright 2020 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.ariaHandler = void 0;
const assert_js_1 = require("../util/assert.js");
const IsolatedWorlds_js_1 = require("./IsolatedWorlds.js");
async function queryAXTree(client, element, accessibleName, role) {
const { nodes } = await client.send('Accessibility.queryAXTree', {
objectId: element.remoteObject().objectId,
accessibleName,
role,
});
const filteredNodes = nodes.filter((node) => {
return !node.role || node.role.value !== 'StaticText';
});
return filteredNodes;
}
const normalizeValue = (value) => {
return value.replace(/ +/g, ' ').trim();
};
const knownAttributes = new Set(['name', 'role']);
const attributeRegexp = /\[\s*(?<attribute>\w+)\s*=\s*(?<quote>"|')(?<value>\\.|.*?(?=\k<quote>))\k<quote>\s*\]/g;
function isKnownAttribute(attribute) {
return knownAttributes.has(attribute);
}
/**
* The selectors consist of an accessible name to query for and optionally
* further aria attributes on the form `[<attribute>=<value>]`.
* Currently, we only support the `name` and `role` attribute.
* The following examples showcase how the syntax works wrt. querying:
*
* - 'title[role="heading"]' queries for elements with name 'title' and role 'heading'.
* - '[role="img"]' queries for elements with role 'img' and any name.
* - 'label' queries for elements with name 'label' and any role.
* - '[name=""][role="button"]' queries for elements with no name and role 'button'.
*/
function parseAriaSelector(selector) {
const queryOptions = {};
const defaultName = selector.replace(attributeRegexp, (_, attribute, _quote, value) => {
attribute = attribute.trim();
(0, assert_js_1.assert)(isKnownAttribute(attribute), `Unknown aria attribute "${attribute}" in selector`);
queryOptions[attribute] = normalizeValue(value);
return '';
});
if (defaultName && !queryOptions.name) {
queryOptions.name = normalizeValue(defaultName);
}
return queryOptions;
}
const queryOneId = async (element, selector) => {
const { name, role } = parseAriaSelector(selector);
const res = await queryAXTree(element.client, element, name, role);
if (!res[0] || !res[0].backendDOMNodeId) {
return null;
}
return res[0].backendDOMNodeId;
};
const queryOne = async (element, selector) => {
const id = await queryOneId(element, selector);
if (!id) {
return null;
}
return (await element.frame.worlds[IsolatedWorlds_js_1.MAIN_WORLD].adoptBackendNode(id));
};
const waitFor = async (elementOrFrame, selector, options) => {
let frame;
let element;
if ('isOOPFrame' in elementOrFrame) {
frame = elementOrFrame;
}
else {
frame = elementOrFrame.frame;
element = await frame.worlds[IsolatedWorlds_js_1.PUPPETEER_WORLD].adoptHandle(elementOrFrame);
}
const ariaQuerySelector = async (selector) => {
const id = await queryOneId(element || (await frame.worlds[IsolatedWorlds_js_1.PUPPETEER_WORLD].document()), selector);
if (!id) {
return null;
}
return (await frame.worlds[IsolatedWorlds_js_1.PUPPETEER_WORLD].adoptBackendNode(id));
};
const result = await frame.worlds[IsolatedWorlds_js_1.PUPPETEER_WORLD]._waitForSelectorInPage((_, selector) => {
return globalThis.ariaQuerySelector(selector);
}, element, selector, options, new Map([['ariaQuerySelector', ariaQuerySelector]]));
if (element) {
await element.dispose();
}
const handle = result === null || result === void 0 ? void 0 : result.asElement();
if (!handle) {
await (result === null || result === void 0 ? void 0 : result.dispose());
return null;
}
return handle.frame.worlds[IsolatedWorlds_js_1.MAIN_WORLD].transferHandle(handle);
};
const queryAll = async (element, selector) => {
const exeCtx = element.executionContext();
const { name, role } = parseAriaSelector(selector);
const res = await queryAXTree(exeCtx._client, element, name, role);
const world = exeCtx._world;
return Promise.all(res.map(axNode => {
return world.adoptBackendNode(axNode.backendDOMNodeId);
}));
};
/**
* @internal
*/
exports.ariaHandler = {
queryOne,
waitFor,
queryAll,
};
//# sourceMappingURL=AriaQueryHandler.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"AriaQueryHandler.js","sourceRoot":"","sources":["../../../../src/common/AriaQueryHandler.ts"],"names":[],"mappings":"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"}

View file

@ -1,290 +0,0 @@
/**
* Copyright 2017 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/// <reference types="node" />
import { ChildProcess } from 'child_process';
import { Connection } from './Connection.js';
import { Page } from '../api/Page.js';
import { Viewport } from './PuppeteerViewport.js';
import { Target } from './Target.js';
import { TargetManager } from './TargetManager.js';
import { Browser as BrowserBase, BrowserCloseCallback, TargetFilterCallback, IsPageTargetCallback, BrowserContextOptions, WaitForTargetOptions, Permission } from '../api/Browser.js';
import { BrowserContext } from '../api/BrowserContext.js';
/**
* @internal
*/
export declare class CDPBrowser extends BrowserBase {
#private;
/**
* @internal
*/
static _create(product: 'firefox' | 'chrome' | undefined, connection: Connection, contextIds: string[], ignoreHTTPSErrors: boolean, defaultViewport?: Viewport | null, process?: ChildProcess, closeCallback?: BrowserCloseCallback, targetFilterCallback?: TargetFilterCallback, isPageTargetCallback?: IsPageTargetCallback): Promise<CDPBrowser>;
/**
* @internal
*/
get _targets(): Map<string, Target>;
/**
* @internal
*/
constructor(product: 'chrome' | 'firefox' | undefined, connection: Connection, contextIds: string[], ignoreHTTPSErrors: boolean, defaultViewport?: Viewport | null, process?: ChildProcess, closeCallback?: BrowserCloseCallback, targetFilterCallback?: TargetFilterCallback, isPageTargetCallback?: IsPageTargetCallback);
/**
* @internal
*/
_attach(): Promise<void>;
/**
* @internal
*/
_detach(): void;
/**
* The spawned browser process. Returns `null` if the browser instance was created with
* {@link Puppeteer.connect}.
*/
process(): ChildProcess | null;
/**
* @internal
*/
_targetManager(): TargetManager;
/**
* @internal
*/
_getIsPageTargetCallback(): IsPageTargetCallback | undefined;
/**
* Creates a new incognito browser context. This won't share cookies/cache with other
* browser contexts.
*
* @example
*
* ```ts
* (async () => {
* const browser = await puppeteer.launch();
* // Create a new incognito browser context.
* const context = await browser.createIncognitoBrowserContext();
* // Create a new page in a pristine context.
* const page = await context.newPage();
* // Do stuff
* await page.goto('https://example.com');
* })();
* ```
*/
createIncognitoBrowserContext(options?: BrowserContextOptions): Promise<CDPBrowserContext>;
/**
* Returns an array of all open browser contexts. In a newly created browser, this will
* return a single instance of {@link BrowserContext}.
*/
browserContexts(): CDPBrowserContext[];
/**
* Returns the default browser context. The default browser context cannot be closed.
*/
defaultBrowserContext(): CDPBrowserContext;
/**
* @internal
*/
_disposeContext(contextId?: string): Promise<void>;
/**
* The browser websocket endpoint which can be used as an argument to
* {@link Puppeteer.connect}.
*
* @returns The Browser websocket url.
*
* @remarks
*
* The format is `ws://${host}:${port}/devtools/browser/<id>`.
*
* You can find the `webSocketDebuggerUrl` from `http://${host}:${port}/json/version`.
* Learn more about the
* {@link https://chromedevtools.github.io/devtools-protocol | devtools protocol} and
* the {@link
* https://chromedevtools.github.io/devtools-protocol/#how-do-i-access-the-browser-target
* | browser endpoint}.
*/
wsEndpoint(): string;
/**
* Promise which resolves to a new {@link Page} object. The Page is created in
* a default browser context.
*/
newPage(): Promise<Page>;
/**
* @internal
*/
_createPageInContext(contextId?: string): Promise<Page>;
/**
* All active targets inside the Browser. In case of multiple browser contexts, returns
* an array with all the targets in all browser contexts.
*/
targets(): Target[];
/**
* The target associated with the browser.
*/
target(): Target;
/**
* Searches for a target in all browser contexts.
*
* @param predicate - A function to be run for every target.
* @returns The first target found that matches the `predicate` function.
*
* @example
*
* An example of finding a target for a page opened via `window.open`:
*
* ```ts
* await page.evaluate(() => window.open('https://www.example.com/'));
* const newWindowTarget = await browser.waitForTarget(
* target => target.url() === 'https://www.example.com/'
* );
* ```
*/
waitForTarget(predicate: (x: Target) => boolean | Promise<boolean>, options?: WaitForTargetOptions): Promise<Target>;
/**
* An array of all open pages inside the Browser.
*
* @remarks
*
* In case of multiple browser contexts, returns an array with all the pages in all
* browser contexts. Non-visible pages, such as `"background_page"`, will not be listed
* here. You can find them using {@link Target.page}.
*/
pages(): Promise<Page[]>;
/**
* A string representing the browser name and version.
*
* @remarks
*
* For headless Chromium, this is similar to `HeadlessChrome/61.0.3153.0`. For
* non-headless, this is similar to `Chrome/61.0.3153.0`.
*
* The format of browser.version() might change with future releases of Chromium.
*/
version(): Promise<string>;
/**
* The browser's original user agent. Pages can override the browser user agent with
* {@link Page.setUserAgent}.
*/
userAgent(): Promise<string>;
/**
* Closes Chromium and all of its pages (if any were opened). The
* {@link CDPBrowser} object itself is considered to be disposed and cannot be
* used anymore.
*/
close(): Promise<void>;
/**
* Disconnects Puppeteer from the browser, but leaves the Chromium process running.
* After calling `disconnect`, the {@link CDPBrowser} object is considered disposed and
* cannot be used anymore.
*/
disconnect(): void;
/**
* Indicates that the browser is connected.
*/
isConnected(): boolean;
}
/**
* @internal
*/
export declare class CDPBrowserContext extends BrowserContext {
#private;
/**
* @internal
*/
constructor(connection: Connection, browser: CDPBrowser, contextId?: string);
get id(): string | undefined;
/**
* An array of all active targets inside the browser context.
*/
targets(): Target[];
/**
* This searches for a target in this specific browser context.
*
* @example
* An example of finding a target for a page opened via `window.open`:
*
* ```ts
* await page.evaluate(() => window.open('https://www.example.com/'));
* const newWindowTarget = await browserContext.waitForTarget(
* target => target.url() === 'https://www.example.com/'
* );
* ```
*
* @param predicate - A function to be run for every target
* @param options - An object of options. Accepts a timeout,
* which is the maximum wait time in milliseconds.
* Pass `0` to disable the timeout. Defaults to 30 seconds.
* @returns Promise which resolves to the first target found
* that matches the `predicate` function.
*/
waitForTarget(predicate: (x: Target) => boolean | Promise<boolean>, options?: {
timeout?: number;
}): Promise<Target>;
/**
* An array of all pages inside the browser context.
*
* @returns Promise which resolves to an array of all open pages.
* Non visible pages, such as `"background_page"`, will not be listed here.
* You can find them using {@link Target.page | the target page}.
*/
pages(): Promise<Page[]>;
/**
* Returns whether BrowserContext is incognito.
* The default browser context is the only non-incognito browser context.
*
* @remarks
* The default browser context cannot be closed.
*/
isIncognito(): boolean;
/**
* @example
*
* ```ts
* const context = browser.defaultBrowserContext();
* await context.overridePermissions('https://html5demos.com', [
* 'geolocation',
* ]);
* ```
*
* @param origin - The origin to grant permissions to, e.g. "https://example.com".
* @param permissions - An array of permissions to grant.
* All permissions that are not listed here will be automatically denied.
*/
overridePermissions(origin: string, permissions: Permission[]): Promise<void>;
/**
* Clears all permission overrides for the browser context.
*
* @example
*
* ```ts
* const context = browser.defaultBrowserContext();
* context.overridePermissions('https://example.com', ['clipboard-read']);
* // do stuff ..
* context.clearPermissionOverrides();
* ```
*/
clearPermissionOverrides(): Promise<void>;
/**
* Creates a new page in the browser context.
*/
newPage(): Promise<Page>;
/**
* The browser this browser context belongs to.
*/
browser(): CDPBrowser;
/**
* Closes the browser context. All the targets that belong to the browser context
* will be closed.
*
* @remarks
* Only incognito browser contexts can be closed.
*/
close(): Promise<void>;
}
//# sourceMappingURL=Browser.d.ts.map

View file

@ -1 +0,0 @@
{"version":3,"file":"Browser.d.ts","sourceRoot":"","sources":["../../../../src/common/Browser.ts"],"names":[],"mappings":"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"}

View file

@ -1,586 +0,0 @@
"use strict";
/**
* Copyright 2017 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var _CDPBrowser_instances, _CDPBrowser_ignoreHTTPSErrors, _CDPBrowser_defaultViewport, _CDPBrowser_process, _CDPBrowser_connection, _CDPBrowser_closeCallback, _CDPBrowser_targetFilterCallback, _CDPBrowser_isPageTargetCallback, _CDPBrowser_defaultContext, _CDPBrowser_contexts, _CDPBrowser_screenshotTaskQueue, _CDPBrowser_targetManager, _CDPBrowser_emitDisconnected, _CDPBrowser_setIsPageTargetCallback, _CDPBrowser_createTarget, _CDPBrowser_onAttachedToTarget, _CDPBrowser_onDetachedFromTarget, _CDPBrowser_onTargetChanged, _CDPBrowser_onTargetDiscovered, _CDPBrowser_getVersion, _CDPBrowserContext_connection, _CDPBrowserContext_browser, _CDPBrowserContext_id;
Object.defineProperty(exports, "__esModule", { value: true });
exports.CDPBrowserContext = exports.CDPBrowser = void 0;
const assert_js_1 = require("../util/assert.js");
const Connection_js_1 = require("./Connection.js");
const util_js_1 = require("./util.js");
const Target_js_1 = require("./Target.js");
const TaskQueue_js_1 = require("./TaskQueue.js");
const ChromeTargetManager_js_1 = require("./ChromeTargetManager.js");
const FirefoxTargetManager_js_1 = require("./FirefoxTargetManager.js");
const Browser_js_1 = require("../api/Browser.js");
const BrowserContext_js_1 = require("../api/BrowserContext.js");
/**
* @internal
*/
class CDPBrowser extends Browser_js_1.Browser {
/**
* @internal
*/
static async _create(product, connection, contextIds, ignoreHTTPSErrors, defaultViewport, process, closeCallback, targetFilterCallback, isPageTargetCallback) {
const browser = new CDPBrowser(product, connection, contextIds, ignoreHTTPSErrors, defaultViewport, process, closeCallback, targetFilterCallback, isPageTargetCallback);
await browser._attach();
return browser;
}
/**
* @internal
*/
get _targets() {
return __classPrivateFieldGet(this, _CDPBrowser_targetManager, "f").getAvailableTargets();
}
/**
* @internal
*/
constructor(product, connection, contextIds, ignoreHTTPSErrors, defaultViewport, process, closeCallback, targetFilterCallback, isPageTargetCallback) {
super();
_CDPBrowser_instances.add(this);
_CDPBrowser_ignoreHTTPSErrors.set(this, void 0);
_CDPBrowser_defaultViewport.set(this, void 0);
_CDPBrowser_process.set(this, void 0);
_CDPBrowser_connection.set(this, void 0);
_CDPBrowser_closeCallback.set(this, void 0);
_CDPBrowser_targetFilterCallback.set(this, void 0);
_CDPBrowser_isPageTargetCallback.set(this, void 0);
_CDPBrowser_defaultContext.set(this, void 0);
_CDPBrowser_contexts.set(this, void 0);
_CDPBrowser_screenshotTaskQueue.set(this, void 0);
_CDPBrowser_targetManager.set(this, void 0);
_CDPBrowser_emitDisconnected.set(this, () => {
this.emit("disconnected" /* BrowserEmittedEvents.Disconnected */);
});
_CDPBrowser_createTarget.set(this, (targetInfo, session) => {
var _a;
const { browserContextId } = targetInfo;
const context = browserContextId && __classPrivateFieldGet(this, _CDPBrowser_contexts, "f").has(browserContextId)
? __classPrivateFieldGet(this, _CDPBrowser_contexts, "f").get(browserContextId)
: __classPrivateFieldGet(this, _CDPBrowser_defaultContext, "f");
if (!context) {
throw new Error('Missing browser context');
}
return new Target_js_1.Target(targetInfo, session, context, __classPrivateFieldGet(this, _CDPBrowser_targetManager, "f"), (isAutoAttachEmulated) => {
return __classPrivateFieldGet(this, _CDPBrowser_connection, "f")._createSession(targetInfo, isAutoAttachEmulated);
}, __classPrivateFieldGet(this, _CDPBrowser_ignoreHTTPSErrors, "f"), (_a = __classPrivateFieldGet(this, _CDPBrowser_defaultViewport, "f")) !== null && _a !== void 0 ? _a : null, __classPrivateFieldGet(this, _CDPBrowser_screenshotTaskQueue, "f"), __classPrivateFieldGet(this, _CDPBrowser_isPageTargetCallback, "f"));
});
_CDPBrowser_onAttachedToTarget.set(this, async (target) => {
if (await target._initializedPromise) {
this.emit("targetcreated" /* BrowserEmittedEvents.TargetCreated */, target);
target
.browserContext()
.emit("targetcreated" /* BrowserContextEmittedEvents.TargetCreated */, target);
}
});
_CDPBrowser_onDetachedFromTarget.set(this, async (target) => {
target._initializedCallback(false);
target._closedCallback();
if (await target._initializedPromise) {
this.emit("targetdestroyed" /* BrowserEmittedEvents.TargetDestroyed */, target);
target
.browserContext()
.emit("targetdestroyed" /* BrowserContextEmittedEvents.TargetDestroyed */, target);
}
});
_CDPBrowser_onTargetChanged.set(this, ({ target, targetInfo, }) => {
const previousURL = target.url();
const wasInitialized = target._isInitialized;
target._targetInfoChanged(targetInfo);
if (wasInitialized && previousURL !== target.url()) {
this.emit("targetchanged" /* BrowserEmittedEvents.TargetChanged */, target);
target
.browserContext()
.emit("targetchanged" /* BrowserContextEmittedEvents.TargetChanged */, target);
}
});
_CDPBrowser_onTargetDiscovered.set(this, (targetInfo) => {
this.emit('targetdiscovered', targetInfo);
});
product = product || 'chrome';
__classPrivateFieldSet(this, _CDPBrowser_ignoreHTTPSErrors, ignoreHTTPSErrors, "f");
__classPrivateFieldSet(this, _CDPBrowser_defaultViewport, defaultViewport, "f");
__classPrivateFieldSet(this, _CDPBrowser_process, process, "f");
__classPrivateFieldSet(this, _CDPBrowser_screenshotTaskQueue, new TaskQueue_js_1.TaskQueue(), "f");
__classPrivateFieldSet(this, _CDPBrowser_connection, connection, "f");
__classPrivateFieldSet(this, _CDPBrowser_closeCallback, closeCallback || function () { }, "f");
__classPrivateFieldSet(this, _CDPBrowser_targetFilterCallback, targetFilterCallback ||
(() => {
return true;
}), "f");
__classPrivateFieldGet(this, _CDPBrowser_instances, "m", _CDPBrowser_setIsPageTargetCallback).call(this, isPageTargetCallback);
if (product === 'firefox') {
__classPrivateFieldSet(this, _CDPBrowser_targetManager, new FirefoxTargetManager_js_1.FirefoxTargetManager(connection, __classPrivateFieldGet(this, _CDPBrowser_createTarget, "f"), __classPrivateFieldGet(this, _CDPBrowser_targetFilterCallback, "f")), "f");
}
else {
__classPrivateFieldSet(this, _CDPBrowser_targetManager, new ChromeTargetManager_js_1.ChromeTargetManager(connection, __classPrivateFieldGet(this, _CDPBrowser_createTarget, "f"), __classPrivateFieldGet(this, _CDPBrowser_targetFilterCallback, "f")), "f");
}
__classPrivateFieldSet(this, _CDPBrowser_defaultContext, new CDPBrowserContext(__classPrivateFieldGet(this, _CDPBrowser_connection, "f"), this), "f");
__classPrivateFieldSet(this, _CDPBrowser_contexts, new Map(), "f");
for (const contextId of contextIds) {
__classPrivateFieldGet(this, _CDPBrowser_contexts, "f").set(contextId, new CDPBrowserContext(__classPrivateFieldGet(this, _CDPBrowser_connection, "f"), this, contextId));
}
}
/**
* @internal
*/
async _attach() {
__classPrivateFieldGet(this, _CDPBrowser_connection, "f").on(Connection_js_1.ConnectionEmittedEvents.Disconnected, __classPrivateFieldGet(this, _CDPBrowser_emitDisconnected, "f"));
__classPrivateFieldGet(this, _CDPBrowser_targetManager, "f").on("targetAvailable" /* TargetManagerEmittedEvents.TargetAvailable */, __classPrivateFieldGet(this, _CDPBrowser_onAttachedToTarget, "f"));
__classPrivateFieldGet(this, _CDPBrowser_targetManager, "f").on("targetGone" /* TargetManagerEmittedEvents.TargetGone */, __classPrivateFieldGet(this, _CDPBrowser_onDetachedFromTarget, "f"));
__classPrivateFieldGet(this, _CDPBrowser_targetManager, "f").on("targetChanged" /* TargetManagerEmittedEvents.TargetChanged */, __classPrivateFieldGet(this, _CDPBrowser_onTargetChanged, "f"));
__classPrivateFieldGet(this, _CDPBrowser_targetManager, "f").on("targetDiscovered" /* TargetManagerEmittedEvents.TargetDiscovered */, __classPrivateFieldGet(this, _CDPBrowser_onTargetDiscovered, "f"));
await __classPrivateFieldGet(this, _CDPBrowser_targetManager, "f").initialize();
}
/**
* @internal
*/
_detach() {
__classPrivateFieldGet(this, _CDPBrowser_connection, "f").off(Connection_js_1.ConnectionEmittedEvents.Disconnected, __classPrivateFieldGet(this, _CDPBrowser_emitDisconnected, "f"));
__classPrivateFieldGet(this, _CDPBrowser_targetManager, "f").off("targetAvailable" /* TargetManagerEmittedEvents.TargetAvailable */, __classPrivateFieldGet(this, _CDPBrowser_onAttachedToTarget, "f"));
__classPrivateFieldGet(this, _CDPBrowser_targetManager, "f").off("targetGone" /* TargetManagerEmittedEvents.TargetGone */, __classPrivateFieldGet(this, _CDPBrowser_onDetachedFromTarget, "f"));
__classPrivateFieldGet(this, _CDPBrowser_targetManager, "f").off("targetChanged" /* TargetManagerEmittedEvents.TargetChanged */, __classPrivateFieldGet(this, _CDPBrowser_onTargetChanged, "f"));
__classPrivateFieldGet(this, _CDPBrowser_targetManager, "f").off("targetDiscovered" /* TargetManagerEmittedEvents.TargetDiscovered */, __classPrivateFieldGet(this, _CDPBrowser_onTargetDiscovered, "f"));
}
/**
* The spawned browser process. Returns `null` if the browser instance was created with
* {@link Puppeteer.connect}.
*/
process() {
var _a;
return (_a = __classPrivateFieldGet(this, _CDPBrowser_process, "f")) !== null && _a !== void 0 ? _a : null;
}
/**
* @internal
*/
_targetManager() {
return __classPrivateFieldGet(this, _CDPBrowser_targetManager, "f");
}
/**
* @internal
*/
_getIsPageTargetCallback() {
return __classPrivateFieldGet(this, _CDPBrowser_isPageTargetCallback, "f");
}
/**
* Creates a new incognito browser context. This won't share cookies/cache with other
* browser contexts.
*
* @example
*
* ```ts
* (async () => {
* const browser = await puppeteer.launch();
* // Create a new incognito browser context.
* const context = await browser.createIncognitoBrowserContext();
* // Create a new page in a pristine context.
* const page = await context.newPage();
* // Do stuff
* await page.goto('https://example.com');
* })();
* ```
*/
async createIncognitoBrowserContext(options = {}) {
const { proxyServer, proxyBypassList } = options;
const { browserContextId } = await __classPrivateFieldGet(this, _CDPBrowser_connection, "f").send('Target.createBrowserContext', {
proxyServer,
proxyBypassList: proxyBypassList && proxyBypassList.join(','),
});
const context = new CDPBrowserContext(__classPrivateFieldGet(this, _CDPBrowser_connection, "f"), this, browserContextId);
__classPrivateFieldGet(this, _CDPBrowser_contexts, "f").set(browserContextId, context);
return context;
}
/**
* Returns an array of all open browser contexts. In a newly created browser, this will
* return a single instance of {@link BrowserContext}.
*/
browserContexts() {
return [__classPrivateFieldGet(this, _CDPBrowser_defaultContext, "f"), ...Array.from(__classPrivateFieldGet(this, _CDPBrowser_contexts, "f").values())];
}
/**
* Returns the default browser context. The default browser context cannot be closed.
*/
defaultBrowserContext() {
return __classPrivateFieldGet(this, _CDPBrowser_defaultContext, "f");
}
/**
* @internal
*/
async _disposeContext(contextId) {
if (!contextId) {
return;
}
await __classPrivateFieldGet(this, _CDPBrowser_connection, "f").send('Target.disposeBrowserContext', {
browserContextId: contextId,
});
__classPrivateFieldGet(this, _CDPBrowser_contexts, "f").delete(contextId);
}
/**
* The browser websocket endpoint which can be used as an argument to
* {@link Puppeteer.connect}.
*
* @returns The Browser websocket url.
*
* @remarks
*
* The format is `ws://${host}:${port}/devtools/browser/<id>`.
*
* You can find the `webSocketDebuggerUrl` from `http://${host}:${port}/json/version`.
* Learn more about the
* {@link https://chromedevtools.github.io/devtools-protocol | devtools protocol} and
* the {@link
* https://chromedevtools.github.io/devtools-protocol/#how-do-i-access-the-browser-target
* | browser endpoint}.
*/
wsEndpoint() {
return __classPrivateFieldGet(this, _CDPBrowser_connection, "f").url();
}
/**
* Promise which resolves to a new {@link Page} object. The Page is created in
* a default browser context.
*/
async newPage() {
return __classPrivateFieldGet(this, _CDPBrowser_defaultContext, "f").newPage();
}
/**
* @internal
*/
async _createPageInContext(contextId) {
const { targetId } = await __classPrivateFieldGet(this, _CDPBrowser_connection, "f").send('Target.createTarget', {
url: 'about:blank',
browserContextId: contextId || undefined,
});
const target = __classPrivateFieldGet(this, _CDPBrowser_targetManager, "f").getAvailableTargets().get(targetId);
if (!target) {
throw new Error(`Missing target for page (id = ${targetId})`);
}
const initialized = await target._initializedPromise;
if (!initialized) {
throw new Error(`Failed to create target for page (id = ${targetId})`);
}
const page = await target.page();
if (!page) {
throw new Error(`Failed to create a page for context (id = ${contextId})`);
}
return page;
}
/**
* All active targets inside the Browser. In case of multiple browser contexts, returns
* an array with all the targets in all browser contexts.
*/
targets() {
return Array.from(__classPrivateFieldGet(this, _CDPBrowser_targetManager, "f").getAvailableTargets().values()).filter(target => {
return target._isInitialized;
});
}
/**
* The target associated with the browser.
*/
target() {
const browserTarget = this.targets().find(target => {
return target.type() === 'browser';
});
if (!browserTarget) {
throw new Error('Browser target is not found');
}
return browserTarget;
}
/**
* Searches for a target in all browser contexts.
*
* @param predicate - A function to be run for every target.
* @returns The first target found that matches the `predicate` function.
*
* @example
*
* An example of finding a target for a page opened via `window.open`:
*
* ```ts
* await page.evaluate(() => window.open('https://www.example.com/'));
* const newWindowTarget = await browser.waitForTarget(
* target => target.url() === 'https://www.example.com/'
* );
* ```
*/
async waitForTarget(predicate, options = {}) {
const { timeout = 30000 } = options;
let resolve;
let isResolved = false;
const targetPromise = new Promise(x => {
return (resolve = x);
});
this.on("targetcreated" /* BrowserEmittedEvents.TargetCreated */, check);
this.on("targetchanged" /* BrowserEmittedEvents.TargetChanged */, check);
try {
this.targets().forEach(check);
if (!timeout) {
return await targetPromise;
}
return await (0, util_js_1.waitWithTimeout)(targetPromise, 'target', timeout);
}
finally {
this.off("targetcreated" /* BrowserEmittedEvents.TargetCreated */, check);
this.off("targetchanged" /* BrowserEmittedEvents.TargetChanged */, check);
}
async function check(target) {
if ((await predicate(target)) && !isResolved) {
isResolved = true;
resolve(target);
}
}
}
/**
* An array of all open pages inside the Browser.
*
* @remarks
*
* In case of multiple browser contexts, returns an array with all the pages in all
* browser contexts. Non-visible pages, such as `"background_page"`, will not be listed
* here. You can find them using {@link Target.page}.
*/
async pages() {
const contextPages = await Promise.all(this.browserContexts().map(context => {
return context.pages();
}));
// Flatten array.
return contextPages.reduce((acc, x) => {
return acc.concat(x);
}, []);
}
/**
* A string representing the browser name and version.
*
* @remarks
*
* For headless Chromium, this is similar to `HeadlessChrome/61.0.3153.0`. For
* non-headless, this is similar to `Chrome/61.0.3153.0`.
*
* The format of browser.version() might change with future releases of Chromium.
*/
async version() {
const version = await __classPrivateFieldGet(this, _CDPBrowser_instances, "m", _CDPBrowser_getVersion).call(this);
return version.product;
}
/**
* The browser's original user agent. Pages can override the browser user agent with
* {@link Page.setUserAgent}.
*/
async userAgent() {
const version = await __classPrivateFieldGet(this, _CDPBrowser_instances, "m", _CDPBrowser_getVersion).call(this);
return version.userAgent;
}
/**
* Closes Chromium and all of its pages (if any were opened). The
* {@link CDPBrowser} object itself is considered to be disposed and cannot be
* used anymore.
*/
async close() {
await __classPrivateFieldGet(this, _CDPBrowser_closeCallback, "f").call(null);
this.disconnect();
}
/**
* Disconnects Puppeteer from the browser, but leaves the Chromium process running.
* After calling `disconnect`, the {@link CDPBrowser} object is considered disposed and
* cannot be used anymore.
*/
disconnect() {
__classPrivateFieldGet(this, _CDPBrowser_targetManager, "f").dispose();
__classPrivateFieldGet(this, _CDPBrowser_connection, "f").dispose();
}
/**
* Indicates that the browser is connected.
*/
isConnected() {
return !__classPrivateFieldGet(this, _CDPBrowser_connection, "f")._closed;
}
}
exports.CDPBrowser = CDPBrowser;
_CDPBrowser_ignoreHTTPSErrors = new WeakMap(), _CDPBrowser_defaultViewport = new WeakMap(), _CDPBrowser_process = new WeakMap(), _CDPBrowser_connection = new WeakMap(), _CDPBrowser_closeCallback = new WeakMap(), _CDPBrowser_targetFilterCallback = new WeakMap(), _CDPBrowser_isPageTargetCallback = new WeakMap(), _CDPBrowser_defaultContext = new WeakMap(), _CDPBrowser_contexts = new WeakMap(), _CDPBrowser_screenshotTaskQueue = new WeakMap(), _CDPBrowser_targetManager = new WeakMap(), _CDPBrowser_emitDisconnected = new WeakMap(), _CDPBrowser_createTarget = new WeakMap(), _CDPBrowser_onAttachedToTarget = new WeakMap(), _CDPBrowser_onDetachedFromTarget = new WeakMap(), _CDPBrowser_onTargetChanged = new WeakMap(), _CDPBrowser_onTargetDiscovered = new WeakMap(), _CDPBrowser_instances = new WeakSet(), _CDPBrowser_setIsPageTargetCallback = function _CDPBrowser_setIsPageTargetCallback(isPageTargetCallback) {
__classPrivateFieldSet(this, _CDPBrowser_isPageTargetCallback, isPageTargetCallback ||
((target) => {
return (target.type === 'page' ||
target.type === 'background_page' ||
target.type === 'webview');
}), "f");
}, _CDPBrowser_getVersion = function _CDPBrowser_getVersion() {
return __classPrivateFieldGet(this, _CDPBrowser_connection, "f").send('Browser.getVersion');
};
/**
* @internal
*/
class CDPBrowserContext extends BrowserContext_js_1.BrowserContext {
/**
* @internal
*/
constructor(connection, browser, contextId) {
super();
_CDPBrowserContext_connection.set(this, void 0);
_CDPBrowserContext_browser.set(this, void 0);
_CDPBrowserContext_id.set(this, void 0);
__classPrivateFieldSet(this, _CDPBrowserContext_connection, connection, "f");
__classPrivateFieldSet(this, _CDPBrowserContext_browser, browser, "f");
__classPrivateFieldSet(this, _CDPBrowserContext_id, contextId, "f");
}
get id() {
return __classPrivateFieldGet(this, _CDPBrowserContext_id, "f");
}
/**
* An array of all active targets inside the browser context.
*/
targets() {
return __classPrivateFieldGet(this, _CDPBrowserContext_browser, "f").targets().filter(target => {
return target.browserContext() === this;
});
}
/**
* This searches for a target in this specific browser context.
*
* @example
* An example of finding a target for a page opened via `window.open`:
*
* ```ts
* await page.evaluate(() => window.open('https://www.example.com/'));
* const newWindowTarget = await browserContext.waitForTarget(
* target => target.url() === 'https://www.example.com/'
* );
* ```
*
* @param predicate - A function to be run for every target
* @param options - An object of options. Accepts a timeout,
* which is the maximum wait time in milliseconds.
* Pass `0` to disable the timeout. Defaults to 30 seconds.
* @returns Promise which resolves to the first target found
* that matches the `predicate` function.
*/
waitForTarget(predicate, options = {}) {
return __classPrivateFieldGet(this, _CDPBrowserContext_browser, "f").waitForTarget(target => {
return target.browserContext() === this && predicate(target);
}, options);
}
/**
* An array of all pages inside the browser context.
*
* @returns Promise which resolves to an array of all open pages.
* Non visible pages, such as `"background_page"`, will not be listed here.
* You can find them using {@link Target.page | the target page}.
*/
async pages() {
const pages = await Promise.all(this.targets()
.filter(target => {
var _a;
return (target.type() === 'page' ||
(target.type() === 'other' &&
((_a = __classPrivateFieldGet(this, _CDPBrowserContext_browser, "f")._getIsPageTargetCallback()) === null || _a === void 0 ? void 0 : _a(target._getTargetInfo()))));
})
.map(target => {
return target.page();
}));
return pages.filter((page) => {
return !!page;
});
}
/**
* Returns whether BrowserContext is incognito.
* The default browser context is the only non-incognito browser context.
*
* @remarks
* The default browser context cannot be closed.
*/
isIncognito() {
return !!__classPrivateFieldGet(this, _CDPBrowserContext_id, "f");
}
/**
* @example
*
* ```ts
* const context = browser.defaultBrowserContext();
* await context.overridePermissions('https://html5demos.com', [
* 'geolocation',
* ]);
* ```
*
* @param origin - The origin to grant permissions to, e.g. "https://example.com".
* @param permissions - An array of permissions to grant.
* All permissions that are not listed here will be automatically denied.
*/
async overridePermissions(origin, permissions) {
const protocolPermissions = permissions.map(permission => {
const protocolPermission = Browser_js_1.WEB_PERMISSION_TO_PROTOCOL_PERMISSION.get(permission);
if (!protocolPermission) {
throw new Error('Unknown permission: ' + permission);
}
return protocolPermission;
});
await __classPrivateFieldGet(this, _CDPBrowserContext_connection, "f").send('Browser.grantPermissions', {
origin,
browserContextId: __classPrivateFieldGet(this, _CDPBrowserContext_id, "f") || undefined,
permissions: protocolPermissions,
});
}
/**
* Clears all permission overrides for the browser context.
*
* @example
*
* ```ts
* const context = browser.defaultBrowserContext();
* context.overridePermissions('https://example.com', ['clipboard-read']);
* // do stuff ..
* context.clearPermissionOverrides();
* ```
*/
async clearPermissionOverrides() {
await __classPrivateFieldGet(this, _CDPBrowserContext_connection, "f").send('Browser.resetPermissions', {
browserContextId: __classPrivateFieldGet(this, _CDPBrowserContext_id, "f") || undefined,
});
}
/**
* Creates a new page in the browser context.
*/
newPage() {
return __classPrivateFieldGet(this, _CDPBrowserContext_browser, "f")._createPageInContext(__classPrivateFieldGet(this, _CDPBrowserContext_id, "f"));
}
/**
* The browser this browser context belongs to.
*/
browser() {
return __classPrivateFieldGet(this, _CDPBrowserContext_browser, "f");
}
/**
* Closes the browser context. All the targets that belong to the browser context
* will be closed.
*
* @remarks
* Only incognito browser contexts can be closed.
*/
async close() {
(0, assert_js_1.assert)(__classPrivateFieldGet(this, _CDPBrowserContext_id, "f"), 'Non-incognito profiles cannot be closed!');
await __classPrivateFieldGet(this, _CDPBrowserContext_browser, "f")._disposeContext(__classPrivateFieldGet(this, _CDPBrowserContext_id, "f"));
}
}
exports.CDPBrowserContext = CDPBrowserContext;
_CDPBrowserContext_connection = new WeakMap(), _CDPBrowserContext_browser = new WeakMap(), _CDPBrowserContext_id = new WeakMap();
//# sourceMappingURL=Browser.js.map

File diff suppressed because one or more lines are too long

View file

@ -1,61 +0,0 @@
/**
* Copyright 2020 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { IsPageTargetCallback, TargetFilterCallback } from '../api/Browser.js';
import { CDPBrowser } from './Browser.js';
import { Viewport } from './PuppeteerViewport.js';
import type { ConnectOptions } from './Puppeteer.js';
/**
* Generic browser options that can be passed when launching any browser or when
* connecting to an existing browser instance.
* @public
*/
export interface BrowserConnectOptions {
/**
* Whether to ignore HTTPS errors during navigation.
* @defaultValue false
*/
ignoreHTTPSErrors?: boolean;
/**
* Sets the viewport for each page.
*/
defaultViewport?: Viewport | null;
/**
* Slows down Puppeteer operations by the specified amount of milliseconds to
* aid debugging.
*/
slowMo?: number;
/**
* Callback to decide if Puppeteer should connect to a given target or not.
*/
targetFilter?: TargetFilterCallback;
/**
* @internal
*/
_isPageTarget?: IsPageTargetCallback;
/**
* @defaultValue 'cdp'
* @internal
*/
protocol?: 'cdp' | 'webDriverBiDi';
}
/**
* Users should never call this directly; it's called when calling
* `puppeteer.connect`.
*
* @internal
*/
export declare function _connectToCDPBrowser(options: BrowserConnectOptions & ConnectOptions): Promise<CDPBrowser>;
//# sourceMappingURL=BrowserConnector.d.ts.map

View file

@ -1 +0,0 @@
{"version":3,"file":"BrowserConnector.d.ts","sourceRoot":"","sources":["../../../../src/common/BrowserConnector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAMH,OAAO,EAAC,oBAAoB,EAAE,oBAAoB,EAAC,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AAIxC,OAAO,EAAC,QAAQ,EAAC,MAAM,wBAAwB,CAAC;AAEhD,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,gBAAgB,CAAC;AACnD;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;OAEG;IACH,eAAe,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;IAClC;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,YAAY,CAAC,EAAE,oBAAoB,CAAC;IACpC;;OAEG;IACH,aAAa,CAAC,EAAE,oBAAoB,CAAC;IACrC;;;OAGG;IACH,QAAQ,CAAC,EAAE,KAAK,GAAG,eAAe,CAAC;CACpC;AASD;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,qBAAqB,GAAG,cAAc,GAC9C,OAAO,CAAC,UAAU,CAAC,CAyDrB"}

View file

@ -1,113 +0,0 @@
"use strict";
/**
* Copyright 2020 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports._connectToCDPBrowser = void 0;
const util_js_1 = require("./util.js");
const ErrorLike_js_1 = require("../util/ErrorLike.js");
const environment_js_1 = require("../environment.js");
const assert_js_1 = require("../util/assert.js");
const Browser_js_1 = require("./Browser.js");
const Connection_js_1 = require("./Connection.js");
const fetch_js_1 = require("./fetch.js");
const getWebSocketTransportClass = async () => {
return environment_js_1.isNode
? (await Promise.resolve().then(() => __importStar(require('./NodeWebSocketTransport.js')))).NodeWebSocketTransport
: (await Promise.resolve().then(() => __importStar(require('./BrowserWebSocketTransport.js'))))
.BrowserWebSocketTransport;
};
/**
* Users should never call this directly; it's called when calling
* `puppeteer.connect`.
*
* @internal
*/
async function _connectToCDPBrowser(options) {
const { browserWSEndpoint, browserURL, ignoreHTTPSErrors = false, defaultViewport = { width: 800, height: 600 }, transport, headers = {}, slowMo = 0, targetFilter, _isPageTarget: isPageTarget, } = options;
(0, assert_js_1.assert)(Number(!!browserWSEndpoint) + Number(!!browserURL) + Number(!!transport) ===
1, 'Exactly one of browserWSEndpoint, browserURL or transport must be passed to puppeteer.connect');
let connection;
if (transport) {
connection = new Connection_js_1.Connection('', transport, slowMo);
}
else if (browserWSEndpoint) {
const WebSocketClass = await getWebSocketTransportClass();
const connectionTransport = await WebSocketClass.create(browserWSEndpoint, headers);
connection = new Connection_js_1.Connection(browserWSEndpoint, connectionTransport, slowMo);
}
else if (browserURL) {
const connectionURL = await getWSEndpoint(browserURL);
const WebSocketClass = await getWebSocketTransportClass();
const connectionTransport = await WebSocketClass.create(connectionURL);
connection = new Connection_js_1.Connection(connectionURL, connectionTransport, slowMo);
}
const version = await connection.send('Browser.getVersion');
const product = version.product.toLowerCase().includes('firefox')
? 'firefox'
: 'chrome';
const { browserContextIds } = await connection.send('Target.getBrowserContexts');
const browser = await Browser_js_1.CDPBrowser._create(product || 'chrome', connection, browserContextIds, ignoreHTTPSErrors, defaultViewport, undefined, () => {
return connection.send('Browser.close').catch(util_js_1.debugError);
}, targetFilter, isPageTarget);
return browser;
}
exports._connectToCDPBrowser = _connectToCDPBrowser;
async function getWSEndpoint(browserURL) {
const endpointURL = new URL('/json/version', browserURL);
const fetch = await (0, fetch_js_1.getFetch)();
try {
const result = await fetch(endpointURL.toString(), {
method: 'GET',
});
if (!result.ok) {
throw new Error(`HTTP ${result.statusText}`);
}
const data = await result.json();
return data.webSocketDebuggerUrl;
}
catch (error) {
if ((0, ErrorLike_js_1.isErrorLike)(error)) {
error.message =
`Failed to fetch browser webSocket URL from ${endpointURL}: ` +
error.message;
}
throw error;
}
}
//# sourceMappingURL=BrowserConnector.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"BrowserConnector.js","sourceRoot":"","sources":["../../../../src/common/BrowserConnector.ts"],"names":[],"mappings":"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"}

View file

@ -1,29 +0,0 @@
/**
* Copyright 2020 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { ConnectionTransport } from './ConnectionTransport.js';
/**
* @internal
*/
export declare class BrowserWebSocketTransport implements ConnectionTransport {
#private;
static create(url: string): Promise<BrowserWebSocketTransport>;
onmessage?: (message: string) => void;
onclose?: () => void;
constructor(ws: WebSocket);
send(message: string): void;
close(): void;
}
//# sourceMappingURL=BrowserWebSocketTransport.d.ts.map

View file

@ -1 +0,0 @@
{"version":3,"file":"BrowserWebSocketTransport.d.ts","sourceRoot":"","sources":["../../../../src/common/BrowserWebSocketTransport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAC,mBAAmB,EAAC,MAAM,0BAA0B,CAAC;AAE7D;;GAEG;AACH,qBAAa,yBAA0B,YAAW,mBAAmB;;IACnE,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,yBAAyB,CAAC;IAY9D,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;gBAET,EAAE,EAAE,SAAS;IAgBzB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAI3B,KAAK,IAAI,IAAI;CAGd"}

View file

@ -1,54 +0,0 @@
"use strict";
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _BrowserWebSocketTransport_ws;
Object.defineProperty(exports, "__esModule", { value: true });
exports.BrowserWebSocketTransport = void 0;
/**
* @internal
*/
class BrowserWebSocketTransport {
static create(url) {
return new Promise((resolve, reject) => {
const ws = new WebSocket(url);
ws.addEventListener('open', () => {
return resolve(new BrowserWebSocketTransport(ws));
});
ws.addEventListener('error', reject);
});
}
constructor(ws) {
_BrowserWebSocketTransport_ws.set(this, void 0);
__classPrivateFieldSet(this, _BrowserWebSocketTransport_ws, ws, "f");
__classPrivateFieldGet(this, _BrowserWebSocketTransport_ws, "f").addEventListener('message', event => {
if (this.onmessage) {
this.onmessage.call(null, event.data);
}
});
__classPrivateFieldGet(this, _BrowserWebSocketTransport_ws, "f").addEventListener('close', () => {
if (this.onclose) {
this.onclose.call(null);
}
});
// Silently ignore all errors - we don't know what to do with them.
__classPrivateFieldGet(this, _BrowserWebSocketTransport_ws, "f").addEventListener('error', () => { });
}
send(message) {
__classPrivateFieldGet(this, _BrowserWebSocketTransport_ws, "f").send(message);
}
close() {
__classPrivateFieldGet(this, _BrowserWebSocketTransport_ws, "f").close();
}
}
exports.BrowserWebSocketTransport = BrowserWebSocketTransport;
_BrowserWebSocketTransport_ws = new WeakMap();
//# sourceMappingURL=BrowserWebSocketTransport.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"BrowserWebSocketTransport.js","sourceRoot":"","sources":["../../../../src/common/BrowserWebSocketTransport.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAiBA;;GAEG;AACH,MAAa,yBAAyB;IACpC,MAAM,CAAC,MAAM,CAAC,GAAW;QACvB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,MAAM,EAAE,GAAG,IAAI,SAAS,CAAC,GAAG,CAAC,CAAC;YAE9B,EAAE,CAAC,gBAAgB,CAAC,MAAM,EAAE,GAAG,EAAE;gBAC/B,OAAO,OAAO,CAAC,IAAI,yBAAyB,CAAC,EAAE,CAAC,CAAC,CAAC;YACpD,CAAC,CAAC,CAAC;YACH,EAAE,CAAC,gBAAgB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACvC,CAAC,CAAC,CAAC;IACL,CAAC;IAMD,YAAY,EAAa;QAJzB,gDAAe;QAKb,uBAAA,IAAI,iCAAO,EAAE,MAAA,CAAC;QACd,uBAAA,IAAI,qCAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,KAAK,CAAC,EAAE;YAC3C,IAAI,IAAI,CAAC,SAAS,EAAE;gBAClB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;aACvC;QACH,CAAC,CAAC,CAAC;QACH,uBAAA,IAAI,qCAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE;YACtC,IAAI,IAAI,CAAC,OAAO,EAAE;gBAChB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aACzB;QACH,CAAC,CAAC,CAAC;QACH,mEAAmE;QACnE,uBAAA,IAAI,qCAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IAC/C,CAAC;IAED,IAAI,CAAC,OAAe;QAClB,uBAAA,IAAI,qCAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC;IAED,KAAK;QACH,uBAAA,IAAI,qCAAI,CAAC,KAAK,EAAE,CAAC;IACnB,CAAC;CACF;AAvCD,8DAuCC"}

View file

@ -1,37 +0,0 @@
/**
* Copyright 2022 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { CDPSession, Connection } from './Connection.js';
import { EventEmitter } from './EventEmitter.js';
import { Target } from './Target.js';
import { TargetFilterCallback } from '../api/Browser.js';
import { TargetInterceptor, TargetFactory, TargetManager } from './TargetManager.js';
/**
* ChromeTargetManager uses the CDP's auto-attach mechanism to intercept
* new targets and allow the rest of Puppeteer to configure listeners while
* the target is paused.
*
* @internal
*/
export declare class ChromeTargetManager extends EventEmitter implements TargetManager {
#private;
constructor(connection: Connection, targetFactory: TargetFactory, targetFilterCallback?: TargetFilterCallback);
initialize(): Promise<void>;
dispose(): void;
getAvailableTargets(): Map<string, Target>;
addTargetInterceptor(session: CDPSession | Connection, interceptor: TargetInterceptor): void;
removeTargetInterceptor(client: CDPSession | Connection, interceptor: TargetInterceptor): void;
}
//# sourceMappingURL=ChromeTargetManager.d.ts.map

View file

@ -1 +0,0 @@
{"version":3,"file":"ChromeTargetManager.d.ts","sourceRoot":"","sources":["../../../../src/common/ChromeTargetManager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,EAAC,UAAU,EAAE,UAAU,EAAC,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAC,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAEnC,OAAO,EAAC,oBAAoB,EAAC,MAAM,mBAAmB,CAAC;AACvD,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,aAAa,EAEd,MAAM,oBAAoB,CAAC;AAE5B;;;;;;GAMG;AACH,qBAAa,mBAAoB,SAAQ,YAAa,YAAW,aAAa;;gBAmD1E,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,aAAa,EAC5B,oBAAoB,CAAC,EAAE,oBAAoB;IAuCvC,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAUjC,OAAO,IAAI,IAAI;IASf,mBAAmB,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IAI1C,oBAAoB,CAClB,OAAO,EAAE,UAAU,GAAG,UAAU,EAChC,WAAW,EAAE,iBAAiB,GAC7B,IAAI;IAMP,uBAAuB,CACrB,MAAM,EAAE,UAAU,GAAG,UAAU,EAC/B,WAAW,EAAE,iBAAiB,GAC7B,IAAI;CA+OR"}

View file

@ -1,306 +0,0 @@
"use strict";
/**
* Copyright 2022 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _ChromeTargetManager_instances, _ChromeTargetManager_connection, _ChromeTargetManager_discoveredTargetsByTargetId, _ChromeTargetManager_attachedTargetsByTargetId, _ChromeTargetManager_attachedTargetsBySessionId, _ChromeTargetManager_ignoredTargets, _ChromeTargetManager_targetFilterCallback, _ChromeTargetManager_targetFactory, _ChromeTargetManager_targetInterceptors, _ChromeTargetManager_attachedToTargetListenersBySession, _ChromeTargetManager_detachedFromTargetListenersBySession, _ChromeTargetManager_initializeCallback, _ChromeTargetManager_initializePromise, _ChromeTargetManager_targetsIdsForInit, _ChromeTargetManager_storeExistingTargetsForInit, _ChromeTargetManager_setupAttachmentListeners, _ChromeTargetManager_removeAttachmentListeners, _ChromeTargetManager_onSessionDetached, _ChromeTargetManager_onTargetCreated, _ChromeTargetManager_onTargetDestroyed, _ChromeTargetManager_onTargetInfoChanged, _ChromeTargetManager_onAttachedToTarget, _ChromeTargetManager_finishInitializationIfReady, _ChromeTargetManager_onDetachedFromTarget;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChromeTargetManager = void 0;
const assert_js_1 = require("../util/assert.js");
const Connection_js_1 = require("./Connection.js");
const EventEmitter_js_1 = require("./EventEmitter.js");
const util_js_1 = require("./util.js");
/**
* ChromeTargetManager uses the CDP's auto-attach mechanism to intercept
* new targets and allow the rest of Puppeteer to configure listeners while
* the target is paused.
*
* @internal
*/
class ChromeTargetManager extends EventEmitter_js_1.EventEmitter {
constructor(connection, targetFactory, targetFilterCallback) {
super();
_ChromeTargetManager_instances.add(this);
_ChromeTargetManager_connection.set(this, void 0);
/**
* Keeps track of the following events: 'Target.targetCreated',
* 'Target.targetDestroyed', 'Target.targetInfoChanged'.
*
* A target becomes discovered when 'Target.targetCreated' is received.
* A target is removed from this map once 'Target.targetDestroyed' is
* received.
*
* `targetFilterCallback` has no effect on this map.
*/
_ChromeTargetManager_discoveredTargetsByTargetId.set(this, new Map());
/**
* A target is added to this map once ChromeTargetManager has created
* a Target and attached at least once to it.
*/
_ChromeTargetManager_attachedTargetsByTargetId.set(this, new Map());
/**
*
* Tracks which sessions attach to which target.
*/
_ChromeTargetManager_attachedTargetsBySessionId.set(this, new Map());
/**
* If a target was filtered out by `targetFilterCallback`, we still receive
* events about it from CDP, but we don't forward them to the rest of Puppeteer.
*/
_ChromeTargetManager_ignoredTargets.set(this, new Set());
_ChromeTargetManager_targetFilterCallback.set(this, void 0);
_ChromeTargetManager_targetFactory.set(this, void 0);
_ChromeTargetManager_targetInterceptors.set(this, new WeakMap());
_ChromeTargetManager_attachedToTargetListenersBySession.set(this, new WeakMap());
_ChromeTargetManager_detachedFromTargetListenersBySession.set(this, new WeakMap());
_ChromeTargetManager_initializeCallback.set(this, () => { });
_ChromeTargetManager_initializePromise.set(this, new Promise(resolve => {
__classPrivateFieldSet(this, _ChromeTargetManager_initializeCallback, resolve, "f");
}));
_ChromeTargetManager_targetsIdsForInit.set(this, new Set());
_ChromeTargetManager_storeExistingTargetsForInit.set(this, () => {
for (const [targetId, targetInfo,] of __classPrivateFieldGet(this, _ChromeTargetManager_discoveredTargetsByTargetId, "f").entries()) {
if ((!__classPrivateFieldGet(this, _ChromeTargetManager_targetFilterCallback, "f") ||
__classPrivateFieldGet(this, _ChromeTargetManager_targetFilterCallback, "f").call(this, targetInfo)) &&
targetInfo.type !== 'browser') {
__classPrivateFieldGet(this, _ChromeTargetManager_targetsIdsForInit, "f").add(targetId);
}
}
});
_ChromeTargetManager_onSessionDetached.set(this, (session) => {
__classPrivateFieldGet(this, _ChromeTargetManager_instances, "m", _ChromeTargetManager_removeAttachmentListeners).call(this, session);
__classPrivateFieldGet(this, _ChromeTargetManager_targetInterceptors, "f").delete(session);
});
_ChromeTargetManager_onTargetCreated.set(this, async (event) => {
__classPrivateFieldGet(this, _ChromeTargetManager_discoveredTargetsByTargetId, "f").set(event.targetInfo.targetId, event.targetInfo);
this.emit("targetDiscovered" /* TargetManagerEmittedEvents.TargetDiscovered */, event.targetInfo);
// The connection is already attached to the browser target implicitly,
// therefore, no new CDPSession is created and we have special handling
// here.
if (event.targetInfo.type === 'browser' && event.targetInfo.attached) {
if (__classPrivateFieldGet(this, _ChromeTargetManager_attachedTargetsByTargetId, "f").has(event.targetInfo.targetId)) {
return;
}
const target = __classPrivateFieldGet(this, _ChromeTargetManager_targetFactory, "f").call(this, event.targetInfo, undefined);
__classPrivateFieldGet(this, _ChromeTargetManager_attachedTargetsByTargetId, "f").set(event.targetInfo.targetId, target);
}
});
_ChromeTargetManager_onTargetDestroyed.set(this, (event) => {
const targetInfo = __classPrivateFieldGet(this, _ChromeTargetManager_discoveredTargetsByTargetId, "f").get(event.targetId);
__classPrivateFieldGet(this, _ChromeTargetManager_discoveredTargetsByTargetId, "f").delete(event.targetId);
__classPrivateFieldGet(this, _ChromeTargetManager_instances, "m", _ChromeTargetManager_finishInitializationIfReady).call(this, event.targetId);
if ((targetInfo === null || targetInfo === void 0 ? void 0 : targetInfo.type) === 'service_worker' &&
__classPrivateFieldGet(this, _ChromeTargetManager_attachedTargetsByTargetId, "f").has(event.targetId)) {
// Special case for service workers: report TargetGone event when
// the worker is destroyed.
const target = __classPrivateFieldGet(this, _ChromeTargetManager_attachedTargetsByTargetId, "f").get(event.targetId);
this.emit("targetGone" /* TargetManagerEmittedEvents.TargetGone */, target);
__classPrivateFieldGet(this, _ChromeTargetManager_attachedTargetsByTargetId, "f").delete(event.targetId);
}
});
_ChromeTargetManager_onTargetInfoChanged.set(this, (event) => {
__classPrivateFieldGet(this, _ChromeTargetManager_discoveredTargetsByTargetId, "f").set(event.targetInfo.targetId, event.targetInfo);
if (__classPrivateFieldGet(this, _ChromeTargetManager_ignoredTargets, "f").has(event.targetInfo.targetId) ||
!__classPrivateFieldGet(this, _ChromeTargetManager_attachedTargetsByTargetId, "f").has(event.targetInfo.targetId) ||
!event.targetInfo.attached) {
return;
}
const target = __classPrivateFieldGet(this, _ChromeTargetManager_attachedTargetsByTargetId, "f").get(event.targetInfo.targetId);
this.emit("targetChanged" /* TargetManagerEmittedEvents.TargetChanged */, {
target: target,
targetInfo: event.targetInfo,
});
});
_ChromeTargetManager_onAttachedToTarget.set(this, async (parentSession, event) => {
const targetInfo = event.targetInfo;
const session = __classPrivateFieldGet(this, _ChromeTargetManager_connection, "f").session(event.sessionId);
if (!session) {
throw new Error(`Session ${event.sessionId} was not created.`);
}
const silentDetach = async () => {
await session.send('Runtime.runIfWaitingForDebugger').catch(util_js_1.debugError);
// We don't use `session.detach()` because that dispatches all commands on
// the connection instead of the parent session.
await parentSession
.send('Target.detachFromTarget', {
sessionId: session.id(),
})
.catch(util_js_1.debugError);
};
if (!__classPrivateFieldGet(this, _ChromeTargetManager_connection, "f").isAutoAttached(targetInfo.targetId)) {
return;
}
// Special case for service workers: being attached to service workers will
// prevent them from ever being destroyed. Therefore, we silently detach
// from service workers unless the connection was manually created via
// `page.worker()`. To determine this, we use
// `this.#connection.isAutoAttached(targetInfo.targetId)`. In the future, we
// should determine if a target is auto-attached or not with the help of
// CDP.
if (targetInfo.type === 'service_worker' &&
__classPrivateFieldGet(this, _ChromeTargetManager_connection, "f").isAutoAttached(targetInfo.targetId)) {
__classPrivateFieldGet(this, _ChromeTargetManager_instances, "m", _ChromeTargetManager_finishInitializationIfReady).call(this, targetInfo.targetId);
await silentDetach();
if (__classPrivateFieldGet(this, _ChromeTargetManager_attachedTargetsByTargetId, "f").has(targetInfo.targetId)) {
return;
}
const target = __classPrivateFieldGet(this, _ChromeTargetManager_targetFactory, "f").call(this, targetInfo);
__classPrivateFieldGet(this, _ChromeTargetManager_attachedTargetsByTargetId, "f").set(targetInfo.targetId, target);
this.emit("targetAvailable" /* TargetManagerEmittedEvents.TargetAvailable */, target);
return;
}
if (__classPrivateFieldGet(this, _ChromeTargetManager_targetFilterCallback, "f") && !__classPrivateFieldGet(this, _ChromeTargetManager_targetFilterCallback, "f").call(this, targetInfo)) {
__classPrivateFieldGet(this, _ChromeTargetManager_ignoredTargets, "f").add(targetInfo.targetId);
__classPrivateFieldGet(this, _ChromeTargetManager_instances, "m", _ChromeTargetManager_finishInitializationIfReady).call(this, targetInfo.targetId);
await silentDetach();
return;
}
const existingTarget = __classPrivateFieldGet(this, _ChromeTargetManager_attachedTargetsByTargetId, "f").has(targetInfo.targetId);
const target = existingTarget
? __classPrivateFieldGet(this, _ChromeTargetManager_attachedTargetsByTargetId, "f").get(targetInfo.targetId)
: __classPrivateFieldGet(this, _ChromeTargetManager_targetFactory, "f").call(this, targetInfo, session);
__classPrivateFieldGet(this, _ChromeTargetManager_instances, "m", _ChromeTargetManager_setupAttachmentListeners).call(this, session);
if (existingTarget) {
__classPrivateFieldGet(this, _ChromeTargetManager_attachedTargetsBySessionId, "f").set(session.id(), __classPrivateFieldGet(this, _ChromeTargetManager_attachedTargetsByTargetId, "f").get(targetInfo.targetId));
}
else {
__classPrivateFieldGet(this, _ChromeTargetManager_attachedTargetsByTargetId, "f").set(targetInfo.targetId, target);
__classPrivateFieldGet(this, _ChromeTargetManager_attachedTargetsBySessionId, "f").set(session.id(), target);
}
for (const interceptor of __classPrivateFieldGet(this, _ChromeTargetManager_targetInterceptors, "f").get(parentSession) ||
[]) {
if (!(parentSession instanceof Connection_js_1.Connection)) {
// Sanity check: if parent session is not a connection, it should be
// present in #attachedTargetsBySessionId.
(0, assert_js_1.assert)(__classPrivateFieldGet(this, _ChromeTargetManager_attachedTargetsBySessionId, "f").has(parentSession.id()));
}
interceptor(target, parentSession instanceof Connection_js_1.Connection
? null
: __classPrivateFieldGet(this, _ChromeTargetManager_attachedTargetsBySessionId, "f").get(parentSession.id()));
}
__classPrivateFieldGet(this, _ChromeTargetManager_targetsIdsForInit, "f").delete(target._targetId);
if (!existingTarget) {
this.emit("targetAvailable" /* TargetManagerEmittedEvents.TargetAvailable */, target);
}
__classPrivateFieldGet(this, _ChromeTargetManager_instances, "m", _ChromeTargetManager_finishInitializationIfReady).call(this);
// TODO: the browser might be shutting down here. What do we do with the
// error?
await Promise.all([
session.send('Target.setAutoAttach', {
waitForDebuggerOnStart: true,
flatten: true,
autoAttach: true,
}),
session.send('Runtime.runIfWaitingForDebugger'),
]).catch(util_js_1.debugError);
});
_ChromeTargetManager_onDetachedFromTarget.set(this, (_parentSession, event) => {
const target = __classPrivateFieldGet(this, _ChromeTargetManager_attachedTargetsBySessionId, "f").get(event.sessionId);
__classPrivateFieldGet(this, _ChromeTargetManager_attachedTargetsBySessionId, "f").delete(event.sessionId);
if (!target) {
return;
}
__classPrivateFieldGet(this, _ChromeTargetManager_attachedTargetsByTargetId, "f").delete(target._targetId);
this.emit("targetGone" /* TargetManagerEmittedEvents.TargetGone */, target);
});
__classPrivateFieldSet(this, _ChromeTargetManager_connection, connection, "f");
__classPrivateFieldSet(this, _ChromeTargetManager_targetFilterCallback, targetFilterCallback, "f");
__classPrivateFieldSet(this, _ChromeTargetManager_targetFactory, targetFactory, "f");
__classPrivateFieldGet(this, _ChromeTargetManager_connection, "f").on('Target.targetCreated', __classPrivateFieldGet(this, _ChromeTargetManager_onTargetCreated, "f"));
__classPrivateFieldGet(this, _ChromeTargetManager_connection, "f").on('Target.targetDestroyed', __classPrivateFieldGet(this, _ChromeTargetManager_onTargetDestroyed, "f"));
__classPrivateFieldGet(this, _ChromeTargetManager_connection, "f").on('Target.targetInfoChanged', __classPrivateFieldGet(this, _ChromeTargetManager_onTargetInfoChanged, "f"));
__classPrivateFieldGet(this, _ChromeTargetManager_connection, "f").on('sessiondetached', __classPrivateFieldGet(this, _ChromeTargetManager_onSessionDetached, "f"));
__classPrivateFieldGet(this, _ChromeTargetManager_instances, "m", _ChromeTargetManager_setupAttachmentListeners).call(this, __classPrivateFieldGet(this, _ChromeTargetManager_connection, "f"));
// TODO: remove `as any` once the protocol definitions are updated with the
// next Chromium roll.
__classPrivateFieldGet(this, _ChromeTargetManager_connection, "f")
.send('Target.setDiscoverTargets', {
discover: true,
filter: [{ type: 'tab', exclude: true }, {}],
})
.then(__classPrivateFieldGet(this, _ChromeTargetManager_storeExistingTargetsForInit, "f"))
.catch(util_js_1.debugError);
}
async initialize() {
await __classPrivateFieldGet(this, _ChromeTargetManager_connection, "f").send('Target.setAutoAttach', {
waitForDebuggerOnStart: true,
flatten: true,
autoAttach: true,
});
__classPrivateFieldGet(this, _ChromeTargetManager_instances, "m", _ChromeTargetManager_finishInitializationIfReady).call(this);
await __classPrivateFieldGet(this, _ChromeTargetManager_initializePromise, "f");
}
dispose() {
__classPrivateFieldGet(this, _ChromeTargetManager_connection, "f").off('Target.targetCreated', __classPrivateFieldGet(this, _ChromeTargetManager_onTargetCreated, "f"));
__classPrivateFieldGet(this, _ChromeTargetManager_connection, "f").off('Target.targetDestroyed', __classPrivateFieldGet(this, _ChromeTargetManager_onTargetDestroyed, "f"));
__classPrivateFieldGet(this, _ChromeTargetManager_connection, "f").off('Target.targetInfoChanged', __classPrivateFieldGet(this, _ChromeTargetManager_onTargetInfoChanged, "f"));
__classPrivateFieldGet(this, _ChromeTargetManager_connection, "f").off('sessiondetached', __classPrivateFieldGet(this, _ChromeTargetManager_onSessionDetached, "f"));
__classPrivateFieldGet(this, _ChromeTargetManager_instances, "m", _ChromeTargetManager_removeAttachmentListeners).call(this, __classPrivateFieldGet(this, _ChromeTargetManager_connection, "f"));
}
getAvailableTargets() {
return __classPrivateFieldGet(this, _ChromeTargetManager_attachedTargetsByTargetId, "f");
}
addTargetInterceptor(session, interceptor) {
const interceptors = __classPrivateFieldGet(this, _ChromeTargetManager_targetInterceptors, "f").get(session) || [];
interceptors.push(interceptor);
__classPrivateFieldGet(this, _ChromeTargetManager_targetInterceptors, "f").set(session, interceptors);
}
removeTargetInterceptor(client, interceptor) {
const interceptors = __classPrivateFieldGet(this, _ChromeTargetManager_targetInterceptors, "f").get(client) || [];
__classPrivateFieldGet(this, _ChromeTargetManager_targetInterceptors, "f").set(client, interceptors.filter(currentInterceptor => {
return currentInterceptor !== interceptor;
}));
}
}
exports.ChromeTargetManager = ChromeTargetManager;
_ChromeTargetManager_connection = new WeakMap(), _ChromeTargetManager_discoveredTargetsByTargetId = new WeakMap(), _ChromeTargetManager_attachedTargetsByTargetId = new WeakMap(), _ChromeTargetManager_attachedTargetsBySessionId = new WeakMap(), _ChromeTargetManager_ignoredTargets = new WeakMap(), _ChromeTargetManager_targetFilterCallback = new WeakMap(), _ChromeTargetManager_targetFactory = new WeakMap(), _ChromeTargetManager_targetInterceptors = new WeakMap(), _ChromeTargetManager_attachedToTargetListenersBySession = new WeakMap(), _ChromeTargetManager_detachedFromTargetListenersBySession = new WeakMap(), _ChromeTargetManager_initializeCallback = new WeakMap(), _ChromeTargetManager_initializePromise = new WeakMap(), _ChromeTargetManager_targetsIdsForInit = new WeakMap(), _ChromeTargetManager_storeExistingTargetsForInit = new WeakMap(), _ChromeTargetManager_onSessionDetached = new WeakMap(), _ChromeTargetManager_onTargetCreated = new WeakMap(), _ChromeTargetManager_onTargetDestroyed = new WeakMap(), _ChromeTargetManager_onTargetInfoChanged = new WeakMap(), _ChromeTargetManager_onAttachedToTarget = new WeakMap(), _ChromeTargetManager_onDetachedFromTarget = new WeakMap(), _ChromeTargetManager_instances = new WeakSet(), _ChromeTargetManager_setupAttachmentListeners = function _ChromeTargetManager_setupAttachmentListeners(session) {
const listener = (event) => {
return __classPrivateFieldGet(this, _ChromeTargetManager_onAttachedToTarget, "f").call(this, session, event);
};
(0, assert_js_1.assert)(!__classPrivateFieldGet(this, _ChromeTargetManager_attachedToTargetListenersBySession, "f").has(session));
__classPrivateFieldGet(this, _ChromeTargetManager_attachedToTargetListenersBySession, "f").set(session, listener);
session.on('Target.attachedToTarget', listener);
const detachedListener = (event) => {
return __classPrivateFieldGet(this, _ChromeTargetManager_onDetachedFromTarget, "f").call(this, session, event);
};
(0, assert_js_1.assert)(!__classPrivateFieldGet(this, _ChromeTargetManager_detachedFromTargetListenersBySession, "f").has(session));
__classPrivateFieldGet(this, _ChromeTargetManager_detachedFromTargetListenersBySession, "f").set(session, detachedListener);
session.on('Target.detachedFromTarget', detachedListener);
}, _ChromeTargetManager_removeAttachmentListeners = function _ChromeTargetManager_removeAttachmentListeners(session) {
if (__classPrivateFieldGet(this, _ChromeTargetManager_attachedToTargetListenersBySession, "f").has(session)) {
session.off('Target.attachedToTarget', __classPrivateFieldGet(this, _ChromeTargetManager_attachedToTargetListenersBySession, "f").get(session));
__classPrivateFieldGet(this, _ChromeTargetManager_attachedToTargetListenersBySession, "f").delete(session);
}
if (__classPrivateFieldGet(this, _ChromeTargetManager_detachedFromTargetListenersBySession, "f").has(session)) {
session.off('Target.detachedFromTarget', __classPrivateFieldGet(this, _ChromeTargetManager_detachedFromTargetListenersBySession, "f").get(session));
__classPrivateFieldGet(this, _ChromeTargetManager_detachedFromTargetListenersBySession, "f").delete(session);
}
}, _ChromeTargetManager_finishInitializationIfReady = function _ChromeTargetManager_finishInitializationIfReady(targetId) {
targetId !== undefined && __classPrivateFieldGet(this, _ChromeTargetManager_targetsIdsForInit, "f").delete(targetId);
if (__classPrivateFieldGet(this, _ChromeTargetManager_targetsIdsForInit, "f").size === 0) {
__classPrivateFieldGet(this, _ChromeTargetManager_initializeCallback, "f").call(this);
}
};
//# sourceMappingURL=ChromeTargetManager.js.map

View file

@ -1,133 +0,0 @@
/**
* Copyright 2022 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Product } from './Product.js';
/**
* Defines experiment options for Puppeteer.
*
* See individual properties for more information.
*
* @public
*/
export interface ExperimentsConfiguration {
/**
* Require Puppeteer to download Chromium for Apple M1.
*
* On Apple M1 devices Puppeteer by default downloads the version for
* Intel's processor which runs via Rosetta. It works without any problems,
* however, with this option, you should get more efficient resource usage
* (CPU and RAM) that could lead to a faster execution time.
*
* Can be overridden by `PUPPETEER_EXPERIMENTAL_CHROMIUM_MAC_ARM`.
*
* @defaultValue `false`
*/
macArmChromiumEnabled?: boolean;
}
/**
* Defines options to configure Puppeteer's behavior during installation and
* runtime.
*
* See individual properties for more information.
*
* @public
*/
export interface Configuration {
/**
* Specifies a certain version of the browser you'd like Puppeteer to use.
*
* Can be overridden by `PUPPETEER_BROWSER_REVISION`.
*
* See {@link PuppeteerNode.launch | puppeteer.launch} on how executable path
* is inferred.
*
* @defaultValue A compatible-revision of the browser.
*/
browserRevision?: string;
/**
* Defines the directory to be used by Puppeteer for caching.
*
* Can be overridden by `PUPPETEER_CACHE_DIR`.
*
* @defaultValue `path.join(os.homedir(), '.cache', 'puppeteer')`
*/
cacheDirectory?: string;
/**
* Specifies the URL prefix that is used to download Chromium.
*
* Can be overridden by `PUPPETEER_DOWNLOAD_HOST`.
*
* @remarks
* This must include the protocol and may even need a path prefix.
*
* @defaultValue Either https://storage.googleapis.com or
* https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central,
* depending on the product.
*/
downloadHost?: string;
/**
* Specifies the path for the downloads folder.
*
* Can be overridden by `PUPPETEER_DOWNLOAD_PATH`.
*
* @defaultValue `<cache>/<product>` where `<cache>` is Puppeteer's cache
* directory and `<product>` is the name of the browser.
*/
downloadPath?: string;
/**
* Specifies an executable path to be used in
* {@link PuppeteerNode.launch | puppeteer.launch}.
*
* Can be overridden by `PUPPETEER_EXECUTABLE_PATH`.
*
* @defaultValue Auto-computed.
*/
executablePath?: string;
/**
* Specifies which browser you'd like Puppeteer to use.
*
* Can be overridden by `PUPPETEER_PRODUCT`.
*
* @defaultValue `'chrome'`
*/
defaultProduct?: Product;
/**
* Defines the directory to be used by Puppeteer for creating temporary files.
*
* Can be overridden by `PUPPETEER_TMP_DIR`.
*
* @defaultValue `os.tmpdir()`
*/
temporaryDirectory?: string;
/**
* Tells Puppeteer to not download during installation.
*
* Can be overridden by `PUPPETEER_SKIP_DOWNLOAD`.
*/
skipDownload?: boolean;
/**
* Tells Puppeteer to log at the given level.
*
* At the moment, any option silences logging.
*
* @defaultValue `undefined`
*/
logLevel?: 'silent' | 'error' | 'warn';
/**
* Defines experimental options for Puppeteer.
*/
experiments?: ExperimentsConfiguration;
}
//# sourceMappingURL=Configuration.d.ts.map

View file

@ -1 +0,0 @@
{"version":3,"file":"Configuration.d.ts","sourceRoot":"","sources":["../../../../src/common/Configuration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAC,OAAO,EAAC,MAAM,cAAc,CAAC;AAErC;;;;;;GAMG;AACH,MAAM,WAAW,wBAAwB;IACvC;;;;;;;;;;;OAWG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;;;;;;OASG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;;;;;;;;OAWG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;;;;OAOG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;;;;OAOG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;;;;OAMG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;IACvC;;OAEG;IACH,WAAW,CAAC,EAAE,wBAAwB,CAAC;CACxC"}

View file

@ -1,18 +0,0 @@
"use strict";
/**
* Copyright 2022 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=Configuration.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"Configuration.js","sourceRoot":"","sources":["../../../../src/common/Configuration.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG"}

View file

@ -1,172 +0,0 @@
import { Protocol } from 'devtools-protocol';
import { ProtocolMapping } from 'devtools-protocol/types/protocol-mapping.js';
import { ConnectionTransport } from './ConnectionTransport.js';
import { EventEmitter } from './EventEmitter.js';
import { ProtocolError } from './Errors.js';
/**
* @public
*/
export { ConnectionTransport, ProtocolMapping };
/**
* @public
*/
export interface ConnectionCallback {
resolve(args: unknown): void;
reject(args: unknown): void;
error: ProtocolError;
method: string;
}
/**
* Internal events that the Connection class emits.
*
* @internal
*/
export declare const ConnectionEmittedEvents: {
readonly Disconnected: symbol;
};
/**
* @public
*/
export declare class Connection extends EventEmitter {
#private;
constructor(url: string, transport: ConnectionTransport, delay?: number);
static fromSession(session: CDPSession): Connection | undefined;
/**
* @internal
*/
get _closed(): boolean;
/**
* @internal
*/
get _sessions(): Map<string, CDPSession>;
/**
* @param sessionId - The session id
* @returns The current CDP session if it exists
*/
session(sessionId: string): CDPSession | null;
url(): string;
send<T extends keyof ProtocolMapping.Commands>(method: T, ...paramArgs: ProtocolMapping.Commands[T]['paramsType']): Promise<ProtocolMapping.Commands[T]['returnType']>;
/**
* @internal
*/
_rawSend(message: Record<string, unknown>): number;
/**
* @internal
*/
protected onMessage(message: string): Promise<void>;
dispose(): void;
/**
* @internal
*/
isAutoAttached(targetId: string): boolean;
/**
* @internal
*/
_createSession(targetInfo: Protocol.Target.TargetInfo, isAutoAttachEmulated?: boolean): Promise<CDPSession>;
/**
* @param targetInfo - The target info
* @returns The CDP session that is created
*/
createSession(targetInfo: Protocol.Target.TargetInfo): Promise<CDPSession>;
}
/**
* @public
*/
export interface CDPSessionOnMessageObject {
id?: number;
method: string;
params: Record<string, unknown>;
error: {
message: string;
data: any;
code: number;
};
result?: any;
}
/**
* Internal events that the CDPSession class emits.
*
* @internal
*/
export declare const CDPSessionEmittedEvents: {
readonly Disconnected: symbol;
};
/**
* The `CDPSession` instances are used to talk raw Chrome Devtools Protocol.
*
* @remarks
*
* Protocol methods can be called with {@link CDPSession.send} method and protocol
* events can be subscribed to with `CDPSession.on` method.
*
* Useful links: {@link https://chromedevtools.github.io/devtools-protocol/ | DevTools Protocol Viewer}
* and {@link https://github.com/aslushnikov/getting-started-with-cdp/blob/HEAD/README.md | Getting Started with DevTools Protocol}.
*
* @example
*
* ```ts
* const client = await page.target().createCDPSession();
* await client.send('Animation.enable');
* client.on('Animation.animationCreated', () =>
* console.log('Animation created!')
* );
* const response = await client.send('Animation.getPlaybackRate');
* console.log('playback rate is ' + response.playbackRate);
* await client.send('Animation.setPlaybackRate', {
* playbackRate: response.playbackRate / 2,
* });
* ```
*
* @public
*/
export declare class CDPSession extends EventEmitter {
/**
* @internal
*/
constructor();
connection(): Connection | undefined;
send<T extends keyof ProtocolMapping.Commands>(method: T, ...paramArgs: ProtocolMapping.Commands[T]['paramsType']): Promise<ProtocolMapping.Commands[T]['returnType']>;
/**
* Detaches the cdpSession from the target. Once detached, the cdpSession object
* won't emit any events and can't be used to send messages.
*/
detach(): Promise<void>;
/**
* Returns the session's id.
*/
id(): string;
}
/**
* @internal
*/
export declare class CDPSessionImpl extends CDPSession {
#private;
/**
* @internal
*/
constructor(connection: Connection, targetType: string, sessionId: string);
connection(): Connection | undefined;
send<T extends keyof ProtocolMapping.Commands>(method: T, ...paramArgs: ProtocolMapping.Commands[T]['paramsType']): Promise<ProtocolMapping.Commands[T]['returnType']>;
/**
* @internal
*/
_onMessage(object: CDPSessionOnMessageObject): void;
/**
* Detaches the cdpSession from the target. Once detached, the cdpSession object
* won't emit any events and can't be used to send messages.
*/
detach(): Promise<void>;
/**
* @internal
*/
_onClosed(): void;
/**
* Returns the session's id.
*/
id(): string;
}
/**
* @internal
*/
export declare function isTargetClosedError(err: Error): boolean;
//# sourceMappingURL=Connection.d.ts.map

View file

@ -1 +0,0 @@
{"version":3,"file":"Connection.d.ts","sourceRoot":"","sources":["../../../../src/common/Connection.ts"],"names":[],"mappings":"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"}

View file

@ -1,405 +0,0 @@
"use strict";
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _Connection_instances, _Connection_url, _Connection_transport, _Connection_delay, _Connection_lastId, _Connection_sessions, _Connection_closed, _Connection_callbacks, _Connection_manuallyAttached, _Connection_onClose, _CDPSessionImpl_sessionId, _CDPSessionImpl_targetType, _CDPSessionImpl_callbacks, _CDPSessionImpl_connection;
Object.defineProperty(exports, "__esModule", { value: true });
exports.isTargetClosedError = exports.CDPSessionImpl = exports.CDPSession = exports.CDPSessionEmittedEvents = exports.Connection = exports.ConnectionEmittedEvents = void 0;
/**
* Copyright 2017 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const assert_js_1 = require("../util/assert.js");
const Debug_js_1 = require("./Debug.js");
const debugProtocolSend = (0, Debug_js_1.debug)('puppeteer:protocol:SEND ►');
const debugProtocolReceive = (0, Debug_js_1.debug)('puppeteer:protocol:RECV ◀');
const EventEmitter_js_1 = require("./EventEmitter.js");
const Errors_js_1 = require("./Errors.js");
/**
* Internal events that the Connection class emits.
*
* @internal
*/
exports.ConnectionEmittedEvents = {
Disconnected: Symbol('Connection.Disconnected'),
};
/**
* @public
*/
class Connection extends EventEmitter_js_1.EventEmitter {
constructor(url, transport, delay = 0) {
super();
_Connection_instances.add(this);
_Connection_url.set(this, void 0);
_Connection_transport.set(this, void 0);
_Connection_delay.set(this, void 0);
_Connection_lastId.set(this, 0);
_Connection_sessions.set(this, new Map());
_Connection_closed.set(this, false);
_Connection_callbacks.set(this, new Map());
_Connection_manuallyAttached.set(this, new Set());
__classPrivateFieldSet(this, _Connection_url, url, "f");
__classPrivateFieldSet(this, _Connection_delay, delay, "f");
__classPrivateFieldSet(this, _Connection_transport, transport, "f");
__classPrivateFieldGet(this, _Connection_transport, "f").onmessage = this.onMessage.bind(this);
__classPrivateFieldGet(this, _Connection_transport, "f").onclose = __classPrivateFieldGet(this, _Connection_instances, "m", _Connection_onClose).bind(this);
}
static fromSession(session) {
return session.connection();
}
/**
* @internal
*/
get _closed() {
return __classPrivateFieldGet(this, _Connection_closed, "f");
}
/**
* @internal
*/
get _sessions() {
return __classPrivateFieldGet(this, _Connection_sessions, "f");
}
/**
* @param sessionId - The session id
* @returns The current CDP session if it exists
*/
session(sessionId) {
return __classPrivateFieldGet(this, _Connection_sessions, "f").get(sessionId) || null;
}
url() {
return __classPrivateFieldGet(this, _Connection_url, "f");
}
send(method, ...paramArgs) {
// There is only ever 1 param arg passed, but the Protocol defines it as an
// array of 0 or 1 items See this comment:
// https://github.com/ChromeDevTools/devtools-protocol/pull/113#issuecomment-412603285
// which explains why the protocol defines the params this way for better
// type-inference.
// So now we check if there are any params or not and deal with them accordingly.
const params = paramArgs.length ? paramArgs[0] : undefined;
const id = this._rawSend({ method, params });
return new Promise((resolve, reject) => {
__classPrivateFieldGet(this, _Connection_callbacks, "f").set(id, {
resolve,
reject,
error: new Errors_js_1.ProtocolError(),
method,
});
});
}
/**
* @internal
*/
_rawSend(message) {
var _a;
const id = __classPrivateFieldSet(this, _Connection_lastId, (_a = __classPrivateFieldGet(this, _Connection_lastId, "f"), ++_a), "f");
const stringifiedMessage = JSON.stringify(Object.assign({}, message, { id }));
debugProtocolSend(stringifiedMessage);
__classPrivateFieldGet(this, _Connection_transport, "f").send(stringifiedMessage);
return id;
}
/**
* @internal
*/
async onMessage(message) {
if (__classPrivateFieldGet(this, _Connection_delay, "f")) {
await new Promise(f => {
return setTimeout(f, __classPrivateFieldGet(this, _Connection_delay, "f"));
});
}
debugProtocolReceive(message);
const object = JSON.parse(message);
if (object.method === 'Target.attachedToTarget') {
const sessionId = object.params.sessionId;
const session = new CDPSessionImpl(this, object.params.targetInfo.type, sessionId);
__classPrivateFieldGet(this, _Connection_sessions, "f").set(sessionId, session);
this.emit('sessionattached', session);
const parentSession = __classPrivateFieldGet(this, _Connection_sessions, "f").get(object.sessionId);
if (parentSession) {
parentSession.emit('sessionattached', session);
}
}
else if (object.method === 'Target.detachedFromTarget') {
const session = __classPrivateFieldGet(this, _Connection_sessions, "f").get(object.params.sessionId);
if (session) {
session._onClosed();
__classPrivateFieldGet(this, _Connection_sessions, "f").delete(object.params.sessionId);
this.emit('sessiondetached', session);
const parentSession = __classPrivateFieldGet(this, _Connection_sessions, "f").get(object.sessionId);
if (parentSession) {
parentSession.emit('sessiondetached', session);
}
}
}
if (object.sessionId) {
const session = __classPrivateFieldGet(this, _Connection_sessions, "f").get(object.sessionId);
if (session) {
session._onMessage(object);
}
}
else if (object.id) {
const callback = __classPrivateFieldGet(this, _Connection_callbacks, "f").get(object.id);
// Callbacks could be all rejected if someone has called `.dispose()`.
if (callback) {
__classPrivateFieldGet(this, _Connection_callbacks, "f").delete(object.id);
if (object.error) {
callback.reject(createProtocolError(callback.error, callback.method, object));
}
else {
callback.resolve(object.result);
}
}
}
else {
this.emit(object.method, object.params);
}
}
dispose() {
__classPrivateFieldGet(this, _Connection_instances, "m", _Connection_onClose).call(this);
__classPrivateFieldGet(this, _Connection_transport, "f").close();
}
/**
* @internal
*/
isAutoAttached(targetId) {
return !__classPrivateFieldGet(this, _Connection_manuallyAttached, "f").has(targetId);
}
/**
* @internal
*/
async _createSession(targetInfo, isAutoAttachEmulated = true) {
if (!isAutoAttachEmulated) {
__classPrivateFieldGet(this, _Connection_manuallyAttached, "f").add(targetInfo.targetId);
}
const { sessionId } = await this.send('Target.attachToTarget', {
targetId: targetInfo.targetId,
flatten: true,
});
__classPrivateFieldGet(this, _Connection_manuallyAttached, "f").delete(targetInfo.targetId);
const session = __classPrivateFieldGet(this, _Connection_sessions, "f").get(sessionId);
if (!session) {
throw new Error('CDPSession creation failed.');
}
return session;
}
/**
* @param targetInfo - The target info
* @returns The CDP session that is created
*/
async createSession(targetInfo) {
return await this._createSession(targetInfo, false);
}
}
exports.Connection = Connection;
_Connection_url = new WeakMap(), _Connection_transport = new WeakMap(), _Connection_delay = new WeakMap(), _Connection_lastId = new WeakMap(), _Connection_sessions = new WeakMap(), _Connection_closed = new WeakMap(), _Connection_callbacks = new WeakMap(), _Connection_manuallyAttached = new WeakMap(), _Connection_instances = new WeakSet(), _Connection_onClose = function _Connection_onClose() {
if (__classPrivateFieldGet(this, _Connection_closed, "f")) {
return;
}
__classPrivateFieldSet(this, _Connection_closed, true, "f");
__classPrivateFieldGet(this, _Connection_transport, "f").onmessage = undefined;
__classPrivateFieldGet(this, _Connection_transport, "f").onclose = undefined;
for (const callback of __classPrivateFieldGet(this, _Connection_callbacks, "f").values()) {
callback.reject(rewriteError(callback.error, `Protocol error (${callback.method}): Target closed.`));
}
__classPrivateFieldGet(this, _Connection_callbacks, "f").clear();
for (const session of __classPrivateFieldGet(this, _Connection_sessions, "f").values()) {
session._onClosed();
}
__classPrivateFieldGet(this, _Connection_sessions, "f").clear();
this.emit(exports.ConnectionEmittedEvents.Disconnected);
};
/**
* Internal events that the CDPSession class emits.
*
* @internal
*/
exports.CDPSessionEmittedEvents = {
Disconnected: Symbol('CDPSession.Disconnected'),
};
/**
* The `CDPSession` instances are used to talk raw Chrome Devtools Protocol.
*
* @remarks
*
* Protocol methods can be called with {@link CDPSession.send} method and protocol
* events can be subscribed to with `CDPSession.on` method.
*
* Useful links: {@link https://chromedevtools.github.io/devtools-protocol/ | DevTools Protocol Viewer}
* and {@link https://github.com/aslushnikov/getting-started-with-cdp/blob/HEAD/README.md | Getting Started with DevTools Protocol}.
*
* @example
*
* ```ts
* const client = await page.target().createCDPSession();
* await client.send('Animation.enable');
* client.on('Animation.animationCreated', () =>
* console.log('Animation created!')
* );
* const response = await client.send('Animation.getPlaybackRate');
* console.log('playback rate is ' + response.playbackRate);
* await client.send('Animation.setPlaybackRate', {
* playbackRate: response.playbackRate / 2,
* });
* ```
*
* @public
*/
class CDPSession extends EventEmitter_js_1.EventEmitter {
/**
* @internal
*/
constructor() {
super();
}
connection() {
throw new Error('Not implemented');
}
send() {
throw new Error('Not implemented');
}
/**
* Detaches the cdpSession from the target. Once detached, the cdpSession object
* won't emit any events and can't be used to send messages.
*/
async detach() {
throw new Error('Not implemented');
}
/**
* Returns the session's id.
*/
id() {
throw new Error('Not implemented');
}
}
exports.CDPSession = CDPSession;
/**
* @internal
*/
class CDPSessionImpl extends CDPSession {
/**
* @internal
*/
constructor(connection, targetType, sessionId) {
super();
_CDPSessionImpl_sessionId.set(this, void 0);
_CDPSessionImpl_targetType.set(this, void 0);
_CDPSessionImpl_callbacks.set(this, new Map());
_CDPSessionImpl_connection.set(this, void 0);
__classPrivateFieldSet(this, _CDPSessionImpl_connection, connection, "f");
__classPrivateFieldSet(this, _CDPSessionImpl_targetType, targetType, "f");
__classPrivateFieldSet(this, _CDPSessionImpl_sessionId, sessionId, "f");
}
connection() {
return __classPrivateFieldGet(this, _CDPSessionImpl_connection, "f");
}
send(method, ...paramArgs) {
if (!__classPrivateFieldGet(this, _CDPSessionImpl_connection, "f")) {
return Promise.reject(new Error(`Protocol error (${method}): Session closed. Most likely the ${__classPrivateFieldGet(this, _CDPSessionImpl_targetType, "f")} has been closed.`));
}
// See the comment in Connection#send explaining why we do this.
const params = paramArgs.length ? paramArgs[0] : undefined;
const id = __classPrivateFieldGet(this, _CDPSessionImpl_connection, "f")._rawSend({
sessionId: __classPrivateFieldGet(this, _CDPSessionImpl_sessionId, "f"),
method,
params,
});
return new Promise((resolve, reject) => {
__classPrivateFieldGet(this, _CDPSessionImpl_callbacks, "f").set(id, {
resolve,
reject,
error: new Errors_js_1.ProtocolError(),
method,
});
});
}
/**
* @internal
*/
_onMessage(object) {
const callback = object.id ? __classPrivateFieldGet(this, _CDPSessionImpl_callbacks, "f").get(object.id) : undefined;
if (object.id && callback) {
__classPrivateFieldGet(this, _CDPSessionImpl_callbacks, "f").delete(object.id);
if (object.error) {
callback.reject(createProtocolError(callback.error, callback.method, object));
}
else {
callback.resolve(object.result);
}
}
else {
(0, assert_js_1.assert)(!object.id);
this.emit(object.method, object.params);
}
}
/**
* Detaches the cdpSession from the target. Once detached, the cdpSession object
* won't emit any events and can't be used to send messages.
*/
async detach() {
if (!__classPrivateFieldGet(this, _CDPSessionImpl_connection, "f")) {
throw new Error(`Session already detached. Most likely the ${__classPrivateFieldGet(this, _CDPSessionImpl_targetType, "f")} has been closed.`);
}
await __classPrivateFieldGet(this, _CDPSessionImpl_connection, "f").send('Target.detachFromTarget', {
sessionId: __classPrivateFieldGet(this, _CDPSessionImpl_sessionId, "f"),
});
}
/**
* @internal
*/
_onClosed() {
for (const callback of __classPrivateFieldGet(this, _CDPSessionImpl_callbacks, "f").values()) {
callback.reject(rewriteError(callback.error, `Protocol error (${callback.method}): Target closed.`));
}
__classPrivateFieldGet(this, _CDPSessionImpl_callbacks, "f").clear();
__classPrivateFieldSet(this, _CDPSessionImpl_connection, undefined, "f");
this.emit(exports.CDPSessionEmittedEvents.Disconnected);
}
/**
* Returns the session's id.
*/
id() {
return __classPrivateFieldGet(this, _CDPSessionImpl_sessionId, "f");
}
}
exports.CDPSessionImpl = CDPSessionImpl;
_CDPSessionImpl_sessionId = new WeakMap(), _CDPSessionImpl_targetType = new WeakMap(), _CDPSessionImpl_callbacks = new WeakMap(), _CDPSessionImpl_connection = new WeakMap();
function createProtocolError(error, method, object) {
let message = `Protocol error (${method}): ${object.error.message}`;
if ('data' in object.error) {
message += ` ${object.error.data}`;
}
return rewriteError(error, message, object.error.message);
}
function rewriteError(error, message, originalMessage) {
error.message = message;
error.originalMessage = originalMessage !== null && originalMessage !== void 0 ? originalMessage : error.originalMessage;
return error;
}
/**
* @internal
*/
function isTargetClosedError(err) {
return (err.message.includes('Target closed') ||
err.message.includes('Session closed'));
}
exports.isTargetClosedError = isTargetClosedError;
//# sourceMappingURL=Connection.js.map

File diff suppressed because one or more lines are too long

View file

@ -1,25 +0,0 @@
/**
* Copyright 2020 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @public
*/
export interface ConnectionTransport {
send(message: string): void;
close(): void;
onmessage?: (message: string) => void;
onclose?: () => void;
}
//# sourceMappingURL=ConnectionTransport.d.ts.map

View file

@ -1 +0,0 @@
{"version":3,"file":"ConnectionTransport.d.ts","sourceRoot":"","sources":["../../../../src/common/ConnectionTransport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,KAAK,IAAI,IAAI,CAAC;IACd,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB"}

View file

@ -1,18 +0,0 @@
"use strict";
/**
* Copyright 2020 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=ConnectionTransport.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"ConnectionTransport.js","sourceRoot":"","sources":["../../../../src/common/ConnectionTransport.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG"}

View file

@ -1,70 +0,0 @@
/**
* Copyright 2020 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { JSHandle } from './JSHandle.js';
/**
* @public
*/
export interface ConsoleMessageLocation {
/**
* URL of the resource if known or `undefined` otherwise.
*/
url?: string;
/**
* 0-based line number in the resource if known or `undefined` otherwise.
*/
lineNumber?: number;
/**
* 0-based column number in the resource if known or `undefined` otherwise.
*/
columnNumber?: number;
}
/**
* The supported types for console messages.
* @public
*/
export type ConsoleMessageType = 'log' | 'debug' | 'info' | 'error' | 'warning' | 'dir' | 'dirxml' | 'table' | 'trace' | 'clear' | 'startGroup' | 'startGroupCollapsed' | 'endGroup' | 'assert' | 'profile' | 'profileEnd' | 'count' | 'timeEnd' | 'verbose';
/**
* ConsoleMessage objects are dispatched by page via the 'console' event.
* @public
*/
export declare class ConsoleMessage {
#private;
/**
* @public
*/
constructor(type: ConsoleMessageType, text: string, args: JSHandle[], stackTraceLocations: ConsoleMessageLocation[]);
/**
* @returns The type of the console message.
*/
type(): ConsoleMessageType;
/**
* @returns The text of the console message.
*/
text(): string;
/**
* @returns An array of arguments passed to the console.
*/
args(): JSHandle[];
/**
* @returns The location of the console message.
*/
location(): ConsoleMessageLocation;
/**
* @returns The array of locations on the stack of the console message.
*/
stackTrace(): ConsoleMessageLocation[];
}
//# sourceMappingURL=ConsoleMessage.d.ts.map

View file

@ -1 +0,0 @@
{"version":3,"file":"ConsoleMessage.d.ts","sourceRoot":"","sources":["../../../../src/common/ConsoleMessage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAC,QAAQ,EAAC,MAAM,eAAe,CAAC;AAEvC;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAC1B,KAAK,GACL,OAAO,GACP,MAAM,GACN,OAAO,GACP,SAAS,GACT,KAAK,GACL,QAAQ,GACR,OAAO,GACP,OAAO,GACP,OAAO,GACP,YAAY,GACZ,qBAAqB,GACrB,UAAU,GACV,QAAQ,GACR,SAAS,GACT,YAAY,GACZ,OAAO,GACP,SAAS,GACT,SAAS,CAAC;AAEd;;;GAGG;AACH,qBAAa,cAAc;;IAMzB;;OAEG;gBAED,IAAI,EAAE,kBAAkB,EACxB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,QAAQ,EAAE,EAChB,mBAAmB,EAAE,sBAAsB,EAAE;IAQ/C;;OAEG;IACH,IAAI,IAAI,kBAAkB;IAI1B;;OAEG;IACH,IAAI,IAAI,MAAM;IAId;;OAEG;IACH,IAAI,IAAI,QAAQ,EAAE;IAIlB;;OAEG;IACH,QAAQ,IAAI,sBAAsB;IAIlC;;OAEG;IACH,UAAU,IAAI,sBAAsB,EAAE;CAGvC"}

View file

@ -1,83 +0,0 @@
"use strict";
/**
* Copyright 2020 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _ConsoleMessage_type, _ConsoleMessage_text, _ConsoleMessage_args, _ConsoleMessage_stackTraceLocations;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConsoleMessage = void 0;
/**
* ConsoleMessage objects are dispatched by page via the 'console' event.
* @public
*/
class ConsoleMessage {
/**
* @public
*/
constructor(type, text, args, stackTraceLocations) {
_ConsoleMessage_type.set(this, void 0);
_ConsoleMessage_text.set(this, void 0);
_ConsoleMessage_args.set(this, void 0);
_ConsoleMessage_stackTraceLocations.set(this, void 0);
__classPrivateFieldSet(this, _ConsoleMessage_type, type, "f");
__classPrivateFieldSet(this, _ConsoleMessage_text, text, "f");
__classPrivateFieldSet(this, _ConsoleMessage_args, args, "f");
__classPrivateFieldSet(this, _ConsoleMessage_stackTraceLocations, stackTraceLocations, "f");
}
/**
* @returns The type of the console message.
*/
type() {
return __classPrivateFieldGet(this, _ConsoleMessage_type, "f");
}
/**
* @returns The text of the console message.
*/
text() {
return __classPrivateFieldGet(this, _ConsoleMessage_text, "f");
}
/**
* @returns An array of arguments passed to the console.
*/
args() {
return __classPrivateFieldGet(this, _ConsoleMessage_args, "f");
}
/**
* @returns The location of the console message.
*/
location() {
var _a;
return (_a = __classPrivateFieldGet(this, _ConsoleMessage_stackTraceLocations, "f")[0]) !== null && _a !== void 0 ? _a : {};
}
/**
* @returns The array of locations on the stack of the console message.
*/
stackTrace() {
return __classPrivateFieldGet(this, _ConsoleMessage_stackTraceLocations, "f");
}
}
exports.ConsoleMessage = ConsoleMessage;
_ConsoleMessage_type = new WeakMap(), _ConsoleMessage_text = new WeakMap(), _ConsoleMessage_args = new WeakMap(), _ConsoleMessage_stackTraceLocations = new WeakMap();
//# sourceMappingURL=ConsoleMessage.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"ConsoleMessage.js","sourceRoot":"","sources":["../../../../src/common/ConsoleMessage.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;AAiDH;;;GAGG;AACH,MAAa,cAAc;IAMzB;;OAEG;IACH,YACE,IAAwB,EACxB,IAAY,EACZ,IAAgB,EAChB,mBAA6C;QAZ/C,uCAA0B;QAC1B,uCAAc;QACd,uCAAkB;QAClB,sDAA+C;QAW7C,uBAAA,IAAI,wBAAS,IAAI,MAAA,CAAC;QAClB,uBAAA,IAAI,wBAAS,IAAI,MAAA,CAAC;QAClB,uBAAA,IAAI,wBAAS,IAAI,MAAA,CAAC;QAClB,uBAAA,IAAI,uCAAwB,mBAAmB,MAAA,CAAC;IAClD,CAAC;IAED;;OAEG;IACH,IAAI;QACF,OAAO,uBAAA,IAAI,4BAAM,CAAC;IACpB,CAAC;IAED;;OAEG;IACH,IAAI;QACF,OAAO,uBAAA,IAAI,4BAAM,CAAC;IACpB,CAAC;IAED;;OAEG;IACH,IAAI;QACF,OAAO,uBAAA,IAAI,4BAAM,CAAC;IACpB,CAAC;IAED;;OAEG;IACH,QAAQ;;QACN,OAAO,MAAA,uBAAA,IAAI,2CAAqB,CAAC,CAAC,CAAC,mCAAI,EAAE,CAAC;IAC5C,CAAC;IAED;;OAEG;IACH,UAAU;QACR,OAAO,uBAAA,IAAI,2CAAqB,CAAC;IACnC,CAAC;CACF;AAvDD,wCAuDC"}

View file

@ -1,191 +0,0 @@
/**
* Copyright 2017 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { PuppeteerEventListener } from './util.js';
import { Protocol } from 'devtools-protocol';
import { CDPSession } from './Connection.js';
/**
* @internal
*/
export { PuppeteerEventListener };
/**
* The CoverageEntry class represents one entry of the coverage report.
* @public
*/
export interface CoverageEntry {
/**
* The URL of the style sheet or script.
*/
url: string;
/**
* The content of the style sheet or script.
*/
text: string;
/**
* The covered range as start and end positions.
*/
ranges: Array<{
start: number;
end: number;
}>;
}
/**
* The CoverageEntry class for JavaScript
* @public
*/
export interface JSCoverageEntry extends CoverageEntry {
/**
* Raw V8 script coverage entry.
*/
rawScriptCoverage?: Protocol.Profiler.ScriptCoverage;
}
/**
* Set of configurable options for JS coverage.
* @public
*/
export interface JSCoverageOptions {
/**
* Whether to reset coverage on every navigation.
*/
resetOnNavigation?: boolean;
/**
* Whether anonymous scripts generated by the page should be reported.
*/
reportAnonymousScripts?: boolean;
/**
* Whether the result includes raw V8 script coverage entries.
*/
includeRawScriptCoverage?: boolean;
/**
* Whether to collect coverage information at the block level.
* If true, coverage will be collected at the block level (this is the default).
* If false, coverage will be collected at the function level.
*/
useBlockCoverage?: boolean;
}
/**
* Set of configurable options for CSS coverage.
* @public
*/
export interface CSSCoverageOptions {
/**
* Whether to reset coverage on every navigation.
*/
resetOnNavigation?: boolean;
}
/**
* The Coverage class provides methods to gathers information about parts of
* JavaScript and CSS that were used by the page.
*
* @remarks
* To output coverage in a form consumable by {@link https://github.com/istanbuljs | Istanbul},
* see {@link https://github.com/istanbuljs/puppeteer-to-istanbul | puppeteer-to-istanbul}.
*
* @example
* An example of using JavaScript and CSS coverage to get percentage of initially
* executed code:
*
* ```ts
* // Enable both JavaScript and CSS coverage
* await Promise.all([
* page.coverage.startJSCoverage(),
* page.coverage.startCSSCoverage(),
* ]);
* // Navigate to page
* await page.goto('https://example.com');
* // Disable both JavaScript and CSS coverage
* const [jsCoverage, cssCoverage] = await Promise.all([
* page.coverage.stopJSCoverage(),
* page.coverage.stopCSSCoverage(),
* ]);
* let totalBytes = 0;
* let usedBytes = 0;
* const coverage = [...jsCoverage, ...cssCoverage];
* for (const entry of coverage) {
* totalBytes += entry.text.length;
* for (const range of entry.ranges) usedBytes += range.end - range.start - 1;
* }
* console.log(`Bytes used: ${(usedBytes / totalBytes) * 100}%`);
* ```
*
* @public
*/
export declare class Coverage {
#private;
constructor(client: CDPSession);
/**
* @param options - Set of configurable options for coverage defaults to
* `resetOnNavigation : true, reportAnonymousScripts : false,`
* `includeRawScriptCoverage : false, useBlockCoverage : true`
* @returns Promise that resolves when coverage is started.
*
* @remarks
* Anonymous scripts are ones that don't have an associated url. These are
* scripts that are dynamically created on the page using `eval` or
* `new Function`. If `reportAnonymousScripts` is set to `true`, anonymous
* scripts URL will start with `debugger://VM` (unless a magic //# sourceURL
* comment is present, in which case that will the be URL).
*/
startJSCoverage(options?: JSCoverageOptions): Promise<void>;
/**
* @returns Promise that resolves to the array of coverage reports for
* all scripts.
*
* @remarks
* JavaScript Coverage doesn't include anonymous scripts by default.
* However, scripts with sourceURLs are reported.
*/
stopJSCoverage(): Promise<JSCoverageEntry[]>;
/**
* @param options - Set of configurable options for coverage, defaults to
* `resetOnNavigation : true`
* @returns Promise that resolves when coverage is started.
*/
startCSSCoverage(options?: CSSCoverageOptions): Promise<void>;
/**
* @returns Promise that resolves to the array of coverage reports
* for all stylesheets.
* @remarks
* CSS Coverage doesn't include dynamically injected style tags
* without sourceURLs.
*/
stopCSSCoverage(): Promise<CoverageEntry[]>;
}
/**
* @public
*/
export declare class JSCoverage {
#private;
constructor(client: CDPSession);
start(options?: {
resetOnNavigation?: boolean;
reportAnonymousScripts?: boolean;
includeRawScriptCoverage?: boolean;
useBlockCoverage?: boolean;
}): Promise<void>;
stop(): Promise<JSCoverageEntry[]>;
}
/**
* @public
*/
export declare class CSSCoverage {
#private;
constructor(client: CDPSession);
start(options?: {
resetOnNavigation?: boolean;
}): Promise<void>;
stop(): Promise<CoverageEntry[]>;
}
//# sourceMappingURL=Coverage.d.ts.map

View file

@ -1 +0,0 @@
{"version":3,"file":"Coverage.d.ts","sourceRoot":"","sources":["../../../../src/common/Coverage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAA+B,sBAAsB,EAAC,MAAM,WAAW,CAAC;AAC/E,OAAO,EAAC,QAAQ,EAAC,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAC,UAAU,EAAC,MAAM,iBAAiB,CAAC;AAK3C;;GAEG;AACH,OAAO,EAAC,sBAAsB,EAAC,CAAC;AAEhC;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,MAAM,EAAE,KAAK,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAC,CAAC,CAAC;CAC7C;AAED;;;GAGG;AACH,MAAM,WAAW,eAAgB,SAAQ,aAAa;IACpD;;OAEG;IACH,iBAAiB,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC,cAAc,CAAC;CACtD;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;OAEG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC;;OAEG;IACH,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,qBAAa,QAAQ;;gBAIP,MAAM,EAAE,UAAU;IAK9B;;;;;;;;;;;;OAYG;IACG,eAAe,CAAC,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IAIrE;;;;;;;OAOG;IACG,cAAc,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;IAIlD;;;;OAIG;IACG,gBAAgB,CAAC,OAAO,GAAE,kBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC;IAIvE;;;;;;OAMG;IACG,eAAe,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;CAGlD;AAED;;GAEG;AACH,qBAAa,UAAU;;gBAUT,MAAM,EAAE,UAAU;IAIxB,KAAK,CACT,OAAO,GAAE;QACP,iBAAiB,CAAC,EAAE,OAAO,CAAC;QAC5B,sBAAsB,CAAC,EAAE,OAAO,CAAC;QACjC,wBAAwB,CAAC,EAAE,OAAO,CAAC;QACnC,gBAAgB,CAAC,EAAE,OAAO,CAAC;KACvB,GACL,OAAO,CAAC,IAAI,CAAC;IAoEV,IAAI,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;CAsCzC;AAED;;GAEG;AACH,qBAAa,WAAW;;gBAQV,MAAM,EAAE,UAAU;IAIxB,KAAK,CAAC,OAAO,GAAE;QAAC,iBAAiB,CAAC,EAAE,OAAO,CAAA;KAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAoDjE,IAAI,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;CA+CvC"}

View file

@ -1,375 +0,0 @@
"use strict";
/**
* Copyright 2017 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _Coverage_jsCoverage, _Coverage_cssCoverage, _JSCoverage_instances, _JSCoverage_client, _JSCoverage_enabled, _JSCoverage_scriptURLs, _JSCoverage_scriptSources, _JSCoverage_eventListeners, _JSCoverage_resetOnNavigation, _JSCoverage_reportAnonymousScripts, _JSCoverage_includeRawScriptCoverage, _JSCoverage_onExecutionContextsCleared, _JSCoverage_onScriptParsed, _CSSCoverage_instances, _CSSCoverage_client, _CSSCoverage_enabled, _CSSCoverage_stylesheetURLs, _CSSCoverage_stylesheetSources, _CSSCoverage_eventListeners, _CSSCoverage_resetOnNavigation, _CSSCoverage_onExecutionContextsCleared, _CSSCoverage_onStyleSheet;
Object.defineProperty(exports, "__esModule", { value: true });
exports.CSSCoverage = exports.JSCoverage = exports.Coverage = void 0;
const assert_js_1 = require("../util/assert.js");
const util_js_1 = require("./util.js");
const ExecutionContext_js_1 = require("./ExecutionContext.js");
const util_js_2 = require("./util.js");
/**
* The Coverage class provides methods to gathers information about parts of
* JavaScript and CSS that were used by the page.
*
* @remarks
* To output coverage in a form consumable by {@link https://github.com/istanbuljs | Istanbul},
* see {@link https://github.com/istanbuljs/puppeteer-to-istanbul | puppeteer-to-istanbul}.
*
* @example
* An example of using JavaScript and CSS coverage to get percentage of initially
* executed code:
*
* ```ts
* // Enable both JavaScript and CSS coverage
* await Promise.all([
* page.coverage.startJSCoverage(),
* page.coverage.startCSSCoverage(),
* ]);
* // Navigate to page
* await page.goto('https://example.com');
* // Disable both JavaScript and CSS coverage
* const [jsCoverage, cssCoverage] = await Promise.all([
* page.coverage.stopJSCoverage(),
* page.coverage.stopCSSCoverage(),
* ]);
* let totalBytes = 0;
* let usedBytes = 0;
* const coverage = [...jsCoverage, ...cssCoverage];
* for (const entry of coverage) {
* totalBytes += entry.text.length;
* for (const range of entry.ranges) usedBytes += range.end - range.start - 1;
* }
* console.log(`Bytes used: ${(usedBytes / totalBytes) * 100}%`);
* ```
*
* @public
*/
class Coverage {
constructor(client) {
_Coverage_jsCoverage.set(this, void 0);
_Coverage_cssCoverage.set(this, void 0);
__classPrivateFieldSet(this, _Coverage_jsCoverage, new JSCoverage(client), "f");
__classPrivateFieldSet(this, _Coverage_cssCoverage, new CSSCoverage(client), "f");
}
/**
* @param options - Set of configurable options for coverage defaults to
* `resetOnNavigation : true, reportAnonymousScripts : false,`
* `includeRawScriptCoverage : false, useBlockCoverage : true`
* @returns Promise that resolves when coverage is started.
*
* @remarks
* Anonymous scripts are ones that don't have an associated url. These are
* scripts that are dynamically created on the page using `eval` or
* `new Function`. If `reportAnonymousScripts` is set to `true`, anonymous
* scripts URL will start with `debugger://VM` (unless a magic //# sourceURL
* comment is present, in which case that will the be URL).
*/
async startJSCoverage(options = {}) {
return await __classPrivateFieldGet(this, _Coverage_jsCoverage, "f").start(options);
}
/**
* @returns Promise that resolves to the array of coverage reports for
* all scripts.
*
* @remarks
* JavaScript Coverage doesn't include anonymous scripts by default.
* However, scripts with sourceURLs are reported.
*/
async stopJSCoverage() {
return await __classPrivateFieldGet(this, _Coverage_jsCoverage, "f").stop();
}
/**
* @param options - Set of configurable options for coverage, defaults to
* `resetOnNavigation : true`
* @returns Promise that resolves when coverage is started.
*/
async startCSSCoverage(options = {}) {
return await __classPrivateFieldGet(this, _Coverage_cssCoverage, "f").start(options);
}
/**
* @returns Promise that resolves to the array of coverage reports
* for all stylesheets.
* @remarks
* CSS Coverage doesn't include dynamically injected style tags
* without sourceURLs.
*/
async stopCSSCoverage() {
return await __classPrivateFieldGet(this, _Coverage_cssCoverage, "f").stop();
}
}
exports.Coverage = Coverage;
_Coverage_jsCoverage = new WeakMap(), _Coverage_cssCoverage = new WeakMap();
/**
* @public
*/
class JSCoverage {
constructor(client) {
_JSCoverage_instances.add(this);
_JSCoverage_client.set(this, void 0);
_JSCoverage_enabled.set(this, false);
_JSCoverage_scriptURLs.set(this, new Map());
_JSCoverage_scriptSources.set(this, new Map());
_JSCoverage_eventListeners.set(this, []);
_JSCoverage_resetOnNavigation.set(this, false);
_JSCoverage_reportAnonymousScripts.set(this, false);
_JSCoverage_includeRawScriptCoverage.set(this, false);
__classPrivateFieldSet(this, _JSCoverage_client, client, "f");
}
async start(options = {}) {
(0, assert_js_1.assert)(!__classPrivateFieldGet(this, _JSCoverage_enabled, "f"), 'JSCoverage is already enabled');
const { resetOnNavigation = true, reportAnonymousScripts = false, includeRawScriptCoverage = false, useBlockCoverage = true, } = options;
__classPrivateFieldSet(this, _JSCoverage_resetOnNavigation, resetOnNavigation, "f");
__classPrivateFieldSet(this, _JSCoverage_reportAnonymousScripts, reportAnonymousScripts, "f");
__classPrivateFieldSet(this, _JSCoverage_includeRawScriptCoverage, includeRawScriptCoverage, "f");
__classPrivateFieldSet(this, _JSCoverage_enabled, true, "f");
__classPrivateFieldGet(this, _JSCoverage_scriptURLs, "f").clear();
__classPrivateFieldGet(this, _JSCoverage_scriptSources, "f").clear();
__classPrivateFieldSet(this, _JSCoverage_eventListeners, [
(0, util_js_1.addEventListener)(__classPrivateFieldGet(this, _JSCoverage_client, "f"), 'Debugger.scriptParsed', __classPrivateFieldGet(this, _JSCoverage_instances, "m", _JSCoverage_onScriptParsed).bind(this)),
(0, util_js_1.addEventListener)(__classPrivateFieldGet(this, _JSCoverage_client, "f"), 'Runtime.executionContextsCleared', __classPrivateFieldGet(this, _JSCoverage_instances, "m", _JSCoverage_onExecutionContextsCleared).bind(this)),
], "f");
await Promise.all([
__classPrivateFieldGet(this, _JSCoverage_client, "f").send('Profiler.enable'),
__classPrivateFieldGet(this, _JSCoverage_client, "f").send('Profiler.startPreciseCoverage', {
callCount: __classPrivateFieldGet(this, _JSCoverage_includeRawScriptCoverage, "f"),
detailed: useBlockCoverage,
}),
__classPrivateFieldGet(this, _JSCoverage_client, "f").send('Debugger.enable'),
__classPrivateFieldGet(this, _JSCoverage_client, "f").send('Debugger.setSkipAllPauses', { skip: true }),
]);
}
async stop() {
(0, assert_js_1.assert)(__classPrivateFieldGet(this, _JSCoverage_enabled, "f"), 'JSCoverage is not enabled');
__classPrivateFieldSet(this, _JSCoverage_enabled, false, "f");
const result = await Promise.all([
__classPrivateFieldGet(this, _JSCoverage_client, "f").send('Profiler.takePreciseCoverage'),
__classPrivateFieldGet(this, _JSCoverage_client, "f").send('Profiler.stopPreciseCoverage'),
__classPrivateFieldGet(this, _JSCoverage_client, "f").send('Profiler.disable'),
__classPrivateFieldGet(this, _JSCoverage_client, "f").send('Debugger.disable'),
]);
(0, util_js_2.removeEventListeners)(__classPrivateFieldGet(this, _JSCoverage_eventListeners, "f"));
const coverage = [];
const profileResponse = result[0];
for (const entry of profileResponse.result) {
let url = __classPrivateFieldGet(this, _JSCoverage_scriptURLs, "f").get(entry.scriptId);
if (!url && __classPrivateFieldGet(this, _JSCoverage_reportAnonymousScripts, "f")) {
url = 'debugger://VM' + entry.scriptId;
}
const text = __classPrivateFieldGet(this, _JSCoverage_scriptSources, "f").get(entry.scriptId);
if (text === undefined || url === undefined) {
continue;
}
const flattenRanges = [];
for (const func of entry.functions) {
flattenRanges.push(...func.ranges);
}
const ranges = convertToDisjointRanges(flattenRanges);
if (!__classPrivateFieldGet(this, _JSCoverage_includeRawScriptCoverage, "f")) {
coverage.push({ url, ranges, text });
}
else {
coverage.push({ url, ranges, text, rawScriptCoverage: entry });
}
}
return coverage;
}
}
exports.JSCoverage = JSCoverage;
_JSCoverage_client = new WeakMap(), _JSCoverage_enabled = new WeakMap(), _JSCoverage_scriptURLs = new WeakMap(), _JSCoverage_scriptSources = new WeakMap(), _JSCoverage_eventListeners = new WeakMap(), _JSCoverage_resetOnNavigation = new WeakMap(), _JSCoverage_reportAnonymousScripts = new WeakMap(), _JSCoverage_includeRawScriptCoverage = new WeakMap(), _JSCoverage_instances = new WeakSet(), _JSCoverage_onExecutionContextsCleared = function _JSCoverage_onExecutionContextsCleared() {
if (!__classPrivateFieldGet(this, _JSCoverage_resetOnNavigation, "f")) {
return;
}
__classPrivateFieldGet(this, _JSCoverage_scriptURLs, "f").clear();
__classPrivateFieldGet(this, _JSCoverage_scriptSources, "f").clear();
}, _JSCoverage_onScriptParsed = async function _JSCoverage_onScriptParsed(event) {
// Ignore puppeteer-injected scripts
if (event.url === ExecutionContext_js_1.EVALUATION_SCRIPT_URL) {
return;
}
// Ignore other anonymous scripts unless the reportAnonymousScripts option is true.
if (!event.url && !__classPrivateFieldGet(this, _JSCoverage_reportAnonymousScripts, "f")) {
return;
}
try {
const response = await __classPrivateFieldGet(this, _JSCoverage_client, "f").send('Debugger.getScriptSource', {
scriptId: event.scriptId,
});
__classPrivateFieldGet(this, _JSCoverage_scriptURLs, "f").set(event.scriptId, event.url);
__classPrivateFieldGet(this, _JSCoverage_scriptSources, "f").set(event.scriptId, response.scriptSource);
}
catch (error) {
// This might happen if the page has already navigated away.
(0, util_js_1.debugError)(error);
}
};
/**
* @public
*/
class CSSCoverage {
constructor(client) {
_CSSCoverage_instances.add(this);
_CSSCoverage_client.set(this, void 0);
_CSSCoverage_enabled.set(this, false);
_CSSCoverage_stylesheetURLs.set(this, new Map());
_CSSCoverage_stylesheetSources.set(this, new Map());
_CSSCoverage_eventListeners.set(this, []);
_CSSCoverage_resetOnNavigation.set(this, false);
__classPrivateFieldSet(this, _CSSCoverage_client, client, "f");
}
async start(options = {}) {
(0, assert_js_1.assert)(!__classPrivateFieldGet(this, _CSSCoverage_enabled, "f"), 'CSSCoverage is already enabled');
const { resetOnNavigation = true } = options;
__classPrivateFieldSet(this, _CSSCoverage_resetOnNavigation, resetOnNavigation, "f");
__classPrivateFieldSet(this, _CSSCoverage_enabled, true, "f");
__classPrivateFieldGet(this, _CSSCoverage_stylesheetURLs, "f").clear();
__classPrivateFieldGet(this, _CSSCoverage_stylesheetSources, "f").clear();
__classPrivateFieldSet(this, _CSSCoverage_eventListeners, [
(0, util_js_1.addEventListener)(__classPrivateFieldGet(this, _CSSCoverage_client, "f"), 'CSS.styleSheetAdded', __classPrivateFieldGet(this, _CSSCoverage_instances, "m", _CSSCoverage_onStyleSheet).bind(this)),
(0, util_js_1.addEventListener)(__classPrivateFieldGet(this, _CSSCoverage_client, "f"), 'Runtime.executionContextsCleared', __classPrivateFieldGet(this, _CSSCoverage_instances, "m", _CSSCoverage_onExecutionContextsCleared).bind(this)),
], "f");
await Promise.all([
__classPrivateFieldGet(this, _CSSCoverage_client, "f").send('DOM.enable'),
__classPrivateFieldGet(this, _CSSCoverage_client, "f").send('CSS.enable'),
__classPrivateFieldGet(this, _CSSCoverage_client, "f").send('CSS.startRuleUsageTracking'),
]);
}
async stop() {
(0, assert_js_1.assert)(__classPrivateFieldGet(this, _CSSCoverage_enabled, "f"), 'CSSCoverage is not enabled');
__classPrivateFieldSet(this, _CSSCoverage_enabled, false, "f");
const ruleTrackingResponse = await __classPrivateFieldGet(this, _CSSCoverage_client, "f").send('CSS.stopRuleUsageTracking');
await Promise.all([
__classPrivateFieldGet(this, _CSSCoverage_client, "f").send('CSS.disable'),
__classPrivateFieldGet(this, _CSSCoverage_client, "f").send('DOM.disable'),
]);
(0, util_js_2.removeEventListeners)(__classPrivateFieldGet(this, _CSSCoverage_eventListeners, "f"));
// aggregate by styleSheetId
const styleSheetIdToCoverage = new Map();
for (const entry of ruleTrackingResponse.ruleUsage) {
let ranges = styleSheetIdToCoverage.get(entry.styleSheetId);
if (!ranges) {
ranges = [];
styleSheetIdToCoverage.set(entry.styleSheetId, ranges);
}
ranges.push({
startOffset: entry.startOffset,
endOffset: entry.endOffset,
count: entry.used ? 1 : 0,
});
}
const coverage = [];
for (const styleSheetId of __classPrivateFieldGet(this, _CSSCoverage_stylesheetURLs, "f").keys()) {
const url = __classPrivateFieldGet(this, _CSSCoverage_stylesheetURLs, "f").get(styleSheetId);
(0, assert_js_1.assert)(typeof url !== 'undefined', `Stylesheet URL is undefined (styleSheetId=${styleSheetId})`);
const text = __classPrivateFieldGet(this, _CSSCoverage_stylesheetSources, "f").get(styleSheetId);
(0, assert_js_1.assert)(typeof text !== 'undefined', `Stylesheet text is undefined (styleSheetId=${styleSheetId})`);
const ranges = convertToDisjointRanges(styleSheetIdToCoverage.get(styleSheetId) || []);
coverage.push({ url, ranges, text });
}
return coverage;
}
}
exports.CSSCoverage = CSSCoverage;
_CSSCoverage_client = new WeakMap(), _CSSCoverage_enabled = new WeakMap(), _CSSCoverage_stylesheetURLs = new WeakMap(), _CSSCoverage_stylesheetSources = new WeakMap(), _CSSCoverage_eventListeners = new WeakMap(), _CSSCoverage_resetOnNavigation = new WeakMap(), _CSSCoverage_instances = new WeakSet(), _CSSCoverage_onExecutionContextsCleared = function _CSSCoverage_onExecutionContextsCleared() {
if (!__classPrivateFieldGet(this, _CSSCoverage_resetOnNavigation, "f")) {
return;
}
__classPrivateFieldGet(this, _CSSCoverage_stylesheetURLs, "f").clear();
__classPrivateFieldGet(this, _CSSCoverage_stylesheetSources, "f").clear();
}, _CSSCoverage_onStyleSheet = async function _CSSCoverage_onStyleSheet(event) {
const header = event.header;
// Ignore anonymous scripts
if (!header.sourceURL) {
return;
}
try {
const response = await __classPrivateFieldGet(this, _CSSCoverage_client, "f").send('CSS.getStyleSheetText', {
styleSheetId: header.styleSheetId,
});
__classPrivateFieldGet(this, _CSSCoverage_stylesheetURLs, "f").set(header.styleSheetId, header.sourceURL);
__classPrivateFieldGet(this, _CSSCoverage_stylesheetSources, "f").set(header.styleSheetId, response.text);
}
catch (error) {
// This might happen if the page has already navigated away.
(0, util_js_1.debugError)(error);
}
};
function convertToDisjointRanges(nestedRanges) {
const points = [];
for (const range of nestedRanges) {
points.push({ offset: range.startOffset, type: 0, range });
points.push({ offset: range.endOffset, type: 1, range });
}
// Sort points to form a valid parenthesis sequence.
points.sort((a, b) => {
// Sort with increasing offsets.
if (a.offset !== b.offset) {
return a.offset - b.offset;
}
// All "end" points should go before "start" points.
if (a.type !== b.type) {
return b.type - a.type;
}
const aLength = a.range.endOffset - a.range.startOffset;
const bLength = b.range.endOffset - b.range.startOffset;
// For two "start" points, the one with longer range goes first.
if (a.type === 0) {
return bLength - aLength;
}
// For two "end" points, the one with shorter range goes first.
return aLength - bLength;
});
const hitCountStack = [];
const results = [];
let lastOffset = 0;
// Run scanning line to intersect all ranges.
for (const point of points) {
if (hitCountStack.length &&
lastOffset < point.offset &&
hitCountStack[hitCountStack.length - 1] > 0) {
const lastResult = results[results.length - 1];
if (lastResult && lastResult.end === lastOffset) {
lastResult.end = point.offset;
}
else {
results.push({ start: lastOffset, end: point.offset });
}
}
lastOffset = point.offset;
if (point.type === 0) {
hitCountStack.push(point.range.count);
}
else {
hitCountStack.pop();
}
}
// Filter out empty ranges.
return results.filter(range => {
return range.end - range.start > 0;
});
}
//# sourceMappingURL=Coverage.js.map

File diff suppressed because one or more lines are too long

View file

@ -1,70 +0,0 @@
/**
* Copyright 2020 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
declare global {
var __PUPPETEER_DEBUG: string;
}
/**
* @internal
*/
export declare function importDebug(): Promise<typeof import('debug')>;
/**
* A debug function that can be used in any environment.
*
* @remarks
* If used in Node, it falls back to the
* {@link https://www.npmjs.com/package/debug | debug module}. In the browser it
* uses `console.log`.
*
* In Node, use the `DEBUG` environment variable to control logging:
*
* ```
* DEBUG=* // logs all channels
* DEBUG=foo // logs the `foo` channel
* DEBUG=foo* // logs any channels starting with `foo`
* ```
*
* In the browser, set `window.__PUPPETEER_DEBUG` to a string:
*
* ```
* window.__PUPPETEER_DEBUG='*'; // logs all channels
* window.__PUPPETEER_DEBUG='foo'; // logs the `foo` channel
* window.__PUPPETEER_DEBUG='foo*'; // logs any channels starting with `foo`
* ```
*
* @example
*
* ```
* const log = debug('Page');
*
* log('new page created')
* // logs "Page: new page created"
* ```
*
* @param prefix - this will be prefixed to each log.
* @returns a function that can be called to log to that debug channel.
*
* @internal
*/
export declare const debug: (prefix: string) => (...args: unknown[]) => void;
/**
* @internal
*/
export declare function setLogCapture(value: boolean): void;
/**
* @internal
*/
export declare function getCapturedLogs(): string[];
//# sourceMappingURL=Debug.d.ts.map

View file

@ -1 +0,0 @@
{"version":3,"file":"Debug.d.ts","sourceRoot":"","sources":["../../../../src/common/Debug.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,CAAC,MAAM,CAAC;IAEb,IAAI,iBAAiB,EAAE,MAAM,CAAC;CAC/B;AAMD;;GAEG;AACH,wBAAsB,WAAW,IAAI,OAAO,CAAC,cAAc,OAAO,CAAC,CAAC,CAKnE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,eAAO,MAAM,KAAK,WAAY,MAAM,eAAc,OAAO,EAAE,KAAK,IAoC/D,CAAC;AAWF;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAGlD;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,MAAM,EAAE,CAE1C"}

View file

@ -1,150 +0,0 @@
"use strict";
/**
* Copyright 2020 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getCapturedLogs = exports.setLogCapture = exports.debug = exports.importDebug = void 0;
const environment_js_1 = require("../environment.js");
/**
* @internal
*/
let debugModule = null;
/**
* @internal
*/
async function importDebug() {
if (!debugModule) {
debugModule = (await Promise.resolve().then(() => __importStar(require('debug')))).default;
}
return debugModule;
}
exports.importDebug = importDebug;
/**
* A debug function that can be used in any environment.
*
* @remarks
* If used in Node, it falls back to the
* {@link https://www.npmjs.com/package/debug | debug module}. In the browser it
* uses `console.log`.
*
* In Node, use the `DEBUG` environment variable to control logging:
*
* ```
* DEBUG=* // logs all channels
* DEBUG=foo // logs the `foo` channel
* DEBUG=foo* // logs any channels starting with `foo`
* ```
*
* In the browser, set `window.__PUPPETEER_DEBUG` to a string:
*
* ```
* window.__PUPPETEER_DEBUG='*'; // logs all channels
* window.__PUPPETEER_DEBUG='foo'; // logs the `foo` channel
* window.__PUPPETEER_DEBUG='foo*'; // logs any channels starting with `foo`
* ```
*
* @example
*
* ```
* const log = debug('Page');
*
* log('new page created')
* // logs "Page: new page created"
* ```
*
* @param prefix - this will be prefixed to each log.
* @returns a function that can be called to log to that debug channel.
*
* @internal
*/
const debug = (prefix) => {
if (environment_js_1.isNode) {
return async (...logArgs) => {
if (captureLogs) {
capturedLogs.push(prefix + logArgs);
}
(await importDebug())(prefix)(logArgs);
};
}
return (...logArgs) => {
const debugLevel = globalThis.__PUPPETEER_DEBUG;
if (!debugLevel) {
return;
}
const everythingShouldBeLogged = debugLevel === '*';
const prefixMatchesDebugLevel = everythingShouldBeLogged ||
/**
* If the debug level is `foo*`, that means we match any prefix that
* starts with `foo`. If the level is `foo`, we match only the prefix
* `foo`.
*/
(debugLevel.endsWith('*')
? prefix.startsWith(debugLevel)
: prefix === debugLevel);
if (!prefixMatchesDebugLevel) {
return;
}
// eslint-disable-next-line no-console
console.log(`${prefix}:`, ...logArgs);
};
};
exports.debug = debug;
/**
* @internal
*/
let capturedLogs = [];
/**
* @internal
*/
let captureLogs = false;
/**
* @internal
*/
function setLogCapture(value) {
capturedLogs = [];
captureLogs = value;
}
exports.setLogCapture = setLogCapture;
/**
* @internal
*/
function getCapturedLogs() {
return capturedLogs;
}
exports.getCapturedLogs = getCapturedLogs;
//# sourceMappingURL=Debug.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"Debug.js","sourceRoot":"","sources":["../../../../src/common/Debug.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,sDAAyC;AAOzC;;GAEG;AACH,IAAI,WAAW,GAAkC,IAAI,CAAC;AACtD;;GAEG;AACI,KAAK,UAAU,WAAW;IAC/B,IAAI,CAAC,WAAW,EAAE;QAChB,WAAW,GAAG,CAAC,wDAAa,OAAO,GAAC,CAAC,CAAC,OAAO,CAAC;KAC/C;IACD,OAAO,WAAW,CAAC;AACrB,CAAC;AALD,kCAKC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACI,MAAM,KAAK,GAAG,CAAC,MAAc,EAAkC,EAAE;IACtE,IAAI,uBAAM,EAAE;QACV,OAAO,KAAK,EAAE,GAAG,OAAkB,EAAE,EAAE;YACrC,IAAI,WAAW,EAAE;gBACf,YAAY,CAAC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,CAAC;aACrC;YACD,CAAC,MAAM,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC;QACzC,CAAC,CAAC;KACH;IAED,OAAO,CAAC,GAAG,OAAkB,EAAQ,EAAE;QACrC,MAAM,UAAU,GAAI,UAAkB,CAAC,iBAAiB,CAAC;QACzD,IAAI,CAAC,UAAU,EAAE;YACf,OAAO;SACR;QAED,MAAM,wBAAwB,GAAG,UAAU,KAAK,GAAG,CAAC;QAEpD,MAAM,uBAAuB,GAC3B,wBAAwB;YACxB;;;;eAIG;YACH,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC;gBACvB,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC;gBAC/B,CAAC,CAAC,MAAM,KAAK,UAAU,CAAC,CAAC;QAE7B,IAAI,CAAC,uBAAuB,EAAE;YAC5B,OAAO;SACR;QAED,sCAAsC;QACtC,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,GAAG,EAAE,GAAG,OAAO,CAAC,CAAC;IACxC,CAAC,CAAC;AACJ,CAAC,CAAC;AApCW,QAAA,KAAK,SAoChB;AAEF;;GAEG;AACH,IAAI,YAAY,GAAa,EAAE,CAAC;AAChC;;GAEG;AACH,IAAI,WAAW,GAAG,KAAK,CAAC;AAExB;;GAEG;AACH,SAAgB,aAAa,CAAC,KAAc;IAC1C,YAAY,GAAG,EAAE,CAAC;IAClB,WAAW,GAAG,KAAK,CAAC;AACtB,CAAC;AAHD,sCAGC;AAED;;GAEG;AACH,SAAgB,eAAe;IAC7B,OAAO,YAAY,CAAC;AACtB,CAAC;AAFD,0CAEC"}

View file

@ -1,52 +0,0 @@
/**
* Copyright 2017 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Viewport } from './PuppeteerViewport.js';
/**
* @public
*/
export interface Device {
userAgent: string;
viewport: Viewport;
}
/**
* A list of devices to be used with {@link Page.emulate}.
*
* @example
*
* ```ts
* import {KnownDevices} from 'puppeteer';
* const iPhone = KnownDevices['iPhone 6'];
*
* (async () => {
* const browser = await puppeteer.launch();
* const page = await browser.newPage();
* await page.emulate(iPhone);
* await page.goto('https://www.google.com');
* // other actions...
* await browser.close();
* })();
* ```
*
* @public
*/
export declare const KnownDevices: Readonly<Record<"Blackberry PlayBook" | "Blackberry PlayBook landscape" | "BlackBerry Z30" | "BlackBerry Z30 landscape" | "Galaxy Note 3" | "Galaxy Note 3 landscape" | "Galaxy Note II" | "Galaxy Note II landscape" | "Galaxy S III" | "Galaxy S III landscape" | "Galaxy S5" | "Galaxy S5 landscape" | "Galaxy S8" | "Galaxy S8 landscape" | "Galaxy S9+" | "Galaxy S9+ landscape" | "Galaxy Tab S4" | "Galaxy Tab S4 landscape" | "iPad" | "iPad landscape" | "iPad (gen 6)" | "iPad (gen 6) landscape" | "iPad (gen 7)" | "iPad (gen 7) landscape" | "iPad Mini" | "iPad Mini landscape" | "iPad Pro" | "iPad Pro landscape" | "iPad Pro 11" | "iPad Pro 11 landscape" | "iPhone 4" | "iPhone 4 landscape" | "iPhone 5" | "iPhone 5 landscape" | "iPhone 6" | "iPhone 6 landscape" | "iPhone 6 Plus" | "iPhone 6 Plus landscape" | "iPhone 7" | "iPhone 7 landscape" | "iPhone 7 Plus" | "iPhone 7 Plus landscape" | "iPhone 8" | "iPhone 8 landscape" | "iPhone 8 Plus" | "iPhone 8 Plus landscape" | "iPhone SE" | "iPhone SE landscape" | "iPhone X" | "iPhone X landscape" | "iPhone XR" | "iPhone XR landscape" | "iPhone 11" | "iPhone 11 landscape" | "iPhone 11 Pro" | "iPhone 11 Pro landscape" | "iPhone 11 Pro Max" | "iPhone 11 Pro Max landscape" | "iPhone 12" | "iPhone 12 landscape" | "iPhone 12 Pro" | "iPhone 12 Pro landscape" | "iPhone 12 Pro Max" | "iPhone 12 Pro Max landscape" | "iPhone 12 Mini" | "iPhone 12 Mini landscape" | "iPhone 13" | "iPhone 13 landscape" | "iPhone 13 Pro" | "iPhone 13 Pro landscape" | "iPhone 13 Pro Max" | "iPhone 13 Pro Max landscape" | "iPhone 13 Mini" | "iPhone 13 Mini landscape" | "JioPhone 2" | "JioPhone 2 landscape" | "Kindle Fire HDX" | "Kindle Fire HDX landscape" | "LG Optimus L70" | "LG Optimus L70 landscape" | "Microsoft Lumia 550" | "Microsoft Lumia 950" | "Microsoft Lumia 950 landscape" | "Nexus 10" | "Nexus 10 landscape" | "Nexus 4" | "Nexus 4 landscape" | "Nexus 5" | "Nexus 5 landscape" | "Nexus 5X" | "Nexus 5X landscape" | "Nexus 6" | "Nexus 6 landscape" | "Nexus 6P" | "Nexus 6P landscape" | "Nexus 7" | "Nexus 7 landscape" | "Nokia Lumia 520" | "Nokia Lumia 520 landscape" | "Nokia N9" | "Nokia N9 landscape" | "Pixel 2" | "Pixel 2 landscape" | "Pixel 2 XL" | "Pixel 2 XL landscape" | "Pixel 3" | "Pixel 3 landscape" | "Pixel 4" | "Pixel 4 landscape" | "Pixel 4a (5G)" | "Pixel 4a (5G) landscape" | "Pixel 5" | "Pixel 5 landscape" | "Moto G4" | "Moto G4 landscape", Device>>;
/**
* @deprecated Import {@link KnownDevices}
*
* @public
*/
export declare const devices: Readonly<Record<"Blackberry PlayBook" | "Blackberry PlayBook landscape" | "BlackBerry Z30" | "BlackBerry Z30 landscape" | "Galaxy Note 3" | "Galaxy Note 3 landscape" | "Galaxy Note II" | "Galaxy Note II landscape" | "Galaxy S III" | "Galaxy S III landscape" | "Galaxy S5" | "Galaxy S5 landscape" | "Galaxy S8" | "Galaxy S8 landscape" | "Galaxy S9+" | "Galaxy S9+ landscape" | "Galaxy Tab S4" | "Galaxy Tab S4 landscape" | "iPad" | "iPad landscape" | "iPad (gen 6)" | "iPad (gen 6) landscape" | "iPad (gen 7)" | "iPad (gen 7) landscape" | "iPad Mini" | "iPad Mini landscape" | "iPad Pro" | "iPad Pro landscape" | "iPad Pro 11" | "iPad Pro 11 landscape" | "iPhone 4" | "iPhone 4 landscape" | "iPhone 5" | "iPhone 5 landscape" | "iPhone 6" | "iPhone 6 landscape" | "iPhone 6 Plus" | "iPhone 6 Plus landscape" | "iPhone 7" | "iPhone 7 landscape" | "iPhone 7 Plus" | "iPhone 7 Plus landscape" | "iPhone 8" | "iPhone 8 landscape" | "iPhone 8 Plus" | "iPhone 8 Plus landscape" | "iPhone SE" | "iPhone SE landscape" | "iPhone X" | "iPhone X landscape" | "iPhone XR" | "iPhone XR landscape" | "iPhone 11" | "iPhone 11 landscape" | "iPhone 11 Pro" | "iPhone 11 Pro landscape" | "iPhone 11 Pro Max" | "iPhone 11 Pro Max landscape" | "iPhone 12" | "iPhone 12 landscape" | "iPhone 12 Pro" | "iPhone 12 Pro landscape" | "iPhone 12 Pro Max" | "iPhone 12 Pro Max landscape" | "iPhone 12 Mini" | "iPhone 12 Mini landscape" | "iPhone 13" | "iPhone 13 landscape" | "iPhone 13 Pro" | "iPhone 13 Pro landscape" | "iPhone 13 Pro Max" | "iPhone 13 Pro Max landscape" | "iPhone 13 Mini" | "iPhone 13 Mini landscape" | "JioPhone 2" | "JioPhone 2 landscape" | "Kindle Fire HDX" | "Kindle Fire HDX landscape" | "LG Optimus L70" | "LG Optimus L70 landscape" | "Microsoft Lumia 550" | "Microsoft Lumia 950" | "Microsoft Lumia 950 landscape" | "Nexus 10" | "Nexus 10 landscape" | "Nexus 4" | "Nexus 4 landscape" | "Nexus 5" | "Nexus 5 landscape" | "Nexus 5X" | "Nexus 5X landscape" | "Nexus 6" | "Nexus 6 landscape" | "Nexus 6P" | "Nexus 6P landscape" | "Nexus 7" | "Nexus 7 landscape" | "Nokia Lumia 520" | "Nokia Lumia 520 landscape" | "Nokia N9" | "Nokia N9 landscape" | "Pixel 2" | "Pixel 2 landscape" | "Pixel 2 XL" | "Pixel 2 XL landscape" | "Pixel 3" | "Pixel 3 landscape" | "Pixel 4" | "Pixel 4 landscape" | "Pixel 4a (5G)" | "Pixel 4a (5G) landscape" | "Pixel 5" | "Pixel 5 landscape" | "Moto G4" | "Moto G4 landscape", Device>>;
//# sourceMappingURL=Device.d.ts.map

View file

@ -1 +0,0 @@
{"version":3,"file":"Device.d.ts","sourceRoot":"","sources":["../../../../src/common/Device.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAC,QAAQ,EAAC,MAAM,wBAAwB,CAAC;AAEhD;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAq+CD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,YAAY,y2EAAoC,CAAC;AAE9D;;;;GAIG;AACH,eAAO,MAAM,OAAO,y2EAAe,CAAC"}

File diff suppressed because one or more lines are too long

View file

@ -1,73 +0,0 @@
/**
* Copyright 2017 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { CDPSession } from './Connection.js';
import { Protocol } from 'devtools-protocol';
/**
* Dialog instances are dispatched by the {@link Page} via the `dialog` event.
*
* @remarks
*
* @example
*
* ```ts
* import puppeteer from 'puppeteer';
*
* (async () => {
* const browser = await puppeteer.launch();
* const page = await browser.newPage();
* page.on('dialog', async dialog => {
* console.log(dialog.message());
* await dialog.dismiss();
* await browser.close();
* });
* page.evaluate(() => alert('1'));
* })();
* ```
*
* @public
*/
export declare class Dialog {
#private;
/**
* @internal
*/
constructor(client: CDPSession, type: Protocol.Page.DialogType, message: string, defaultValue?: string);
/**
* @returns The type of the dialog.
*/
type(): Protocol.Page.DialogType;
/**
* @returns The message displayed in the dialog.
*/
message(): string;
/**
* @returns The default value of the prompt, or an empty string if the dialog
* is not a `prompt`.
*/
defaultValue(): string;
/**
* @param promptText - optional text that will be entered in the dialog
* prompt. Has no effect if the dialog's type is not `prompt`.
*
* @returns A promise that resolves when the dialog has been accepted.
*/
accept(promptText?: string): Promise<void>;
/**
* @returns A promise which will resolve once the dialog has been dismissed
*/
dismiss(): Promise<void>;
}
//# sourceMappingURL=Dialog.d.ts.map

View file

@ -1 +0,0 @@
{"version":3,"file":"Dialog.d.ts","sourceRoot":"","sources":["../../../../src/common/Dialog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAC,UAAU,EAAC,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAC,QAAQ,EAAC,MAAM,mBAAmB,CAAC;AAE3C;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,MAAM;;IAOjB;;OAEG;gBAED,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,UAAU,EAC9B,OAAO,EAAE,MAAM,EACf,YAAY,SAAK;IAQnB;;OAEG;IACH,IAAI,IAAI,QAAQ,CAAC,IAAI,CAAC,UAAU;IAIhC;;OAEG;IACH,OAAO,IAAI,MAAM;IAIjB;;;OAGG;IACH,YAAY,IAAI,MAAM;IAItB;;;;;OAKG;IACG,MAAM,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAShD;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAO/B"}

View file

@ -1,117 +0,0 @@
"use strict";
/**
* Copyright 2017 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _Dialog_client, _Dialog_type, _Dialog_message, _Dialog_defaultValue, _Dialog_handled;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Dialog = void 0;
const assert_js_1 = require("../util/assert.js");
/**
* Dialog instances are dispatched by the {@link Page} via the `dialog` event.
*
* @remarks
*
* @example
*
* ```ts
* import puppeteer from 'puppeteer';
*
* (async () => {
* const browser = await puppeteer.launch();
* const page = await browser.newPage();
* page.on('dialog', async dialog => {
* console.log(dialog.message());
* await dialog.dismiss();
* await browser.close();
* });
* page.evaluate(() => alert('1'));
* })();
* ```
*
* @public
*/
class Dialog {
/**
* @internal
*/
constructor(client, type, message, defaultValue = '') {
_Dialog_client.set(this, void 0);
_Dialog_type.set(this, void 0);
_Dialog_message.set(this, void 0);
_Dialog_defaultValue.set(this, void 0);
_Dialog_handled.set(this, false);
__classPrivateFieldSet(this, _Dialog_client, client, "f");
__classPrivateFieldSet(this, _Dialog_type, type, "f");
__classPrivateFieldSet(this, _Dialog_message, message, "f");
__classPrivateFieldSet(this, _Dialog_defaultValue, defaultValue, "f");
}
/**
* @returns The type of the dialog.
*/
type() {
return __classPrivateFieldGet(this, _Dialog_type, "f");
}
/**
* @returns The message displayed in the dialog.
*/
message() {
return __classPrivateFieldGet(this, _Dialog_message, "f");
}
/**
* @returns The default value of the prompt, or an empty string if the dialog
* is not a `prompt`.
*/
defaultValue() {
return __classPrivateFieldGet(this, _Dialog_defaultValue, "f");
}
/**
* @param promptText - optional text that will be entered in the dialog
* prompt. Has no effect if the dialog's type is not `prompt`.
*
* @returns A promise that resolves when the dialog has been accepted.
*/
async accept(promptText) {
(0, assert_js_1.assert)(!__classPrivateFieldGet(this, _Dialog_handled, "f"), 'Cannot accept dialog which is already handled!');
__classPrivateFieldSet(this, _Dialog_handled, true, "f");
await __classPrivateFieldGet(this, _Dialog_client, "f").send('Page.handleJavaScriptDialog', {
accept: true,
promptText: promptText,
});
}
/**
* @returns A promise which will resolve once the dialog has been dismissed
*/
async dismiss() {
(0, assert_js_1.assert)(!__classPrivateFieldGet(this, _Dialog_handled, "f"), 'Cannot dismiss dialog which is already handled!');
__classPrivateFieldSet(this, _Dialog_handled, true, "f");
await __classPrivateFieldGet(this, _Dialog_client, "f").send('Page.handleJavaScriptDialog', {
accept: false,
});
}
}
exports.Dialog = Dialog;
_Dialog_client = new WeakMap(), _Dialog_type = new WeakMap(), _Dialog_message = new WeakMap(), _Dialog_defaultValue = new WeakMap(), _Dialog_handled = new WeakMap();
//# sourceMappingURL=Dialog.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"Dialog.js","sourceRoot":"","sources":["../../../../src/common/Dialog.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;AAEH,iDAAyC;AAIzC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAa,MAAM;IAOjB;;OAEG;IACH,YACE,MAAkB,EAClB,IAA8B,EAC9B,OAAe,EACf,YAAY,GAAG,EAAE;QAbnB,iCAAoB;QACpB,+BAAgC;QAChC,kCAAiB;QACjB,uCAAsB;QACtB,0BAAW,KAAK,EAAC;QAWf,uBAAA,IAAI,kBAAW,MAAM,MAAA,CAAC;QACtB,uBAAA,IAAI,gBAAS,IAAI,MAAA,CAAC;QAClB,uBAAA,IAAI,mBAAY,OAAO,MAAA,CAAC;QACxB,uBAAA,IAAI,wBAAiB,YAAY,MAAA,CAAC;IACpC,CAAC;IAED;;OAEG;IACH,IAAI;QACF,OAAO,uBAAA,IAAI,oBAAM,CAAC;IACpB,CAAC;IAED;;OAEG;IACH,OAAO;QACL,OAAO,uBAAA,IAAI,uBAAS,CAAC;IACvB,CAAC;IAED;;;OAGG;IACH,YAAY;QACV,OAAO,uBAAA,IAAI,4BAAc,CAAC;IAC5B,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,MAAM,CAAC,UAAmB;QAC9B,IAAA,kBAAM,EAAC,CAAC,uBAAA,IAAI,uBAAS,EAAE,gDAAgD,CAAC,CAAC;QACzE,uBAAA,IAAI,mBAAY,IAAI,MAAA,CAAC;QACrB,MAAM,uBAAA,IAAI,sBAAQ,CAAC,IAAI,CAAC,6BAA6B,EAAE;YACrD,MAAM,EAAE,IAAI;YACZ,UAAU,EAAE,UAAU;SACvB,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAO;QACX,IAAA,kBAAM,EAAC,CAAC,uBAAA,IAAI,uBAAS,EAAE,iDAAiD,CAAC,CAAC;QAC1E,uBAAA,IAAI,mBAAY,IAAI,MAAA,CAAC;QACrB,MAAM,uBAAA,IAAI,sBAAQ,CAAC,IAAI,CAAC,6BAA6B,EAAE;YACrD,MAAM,EAAE,KAAK;SACd,CAAC,CAAC;IACL,CAAC;CACF;AArED,wBAqEC"}

Some files were not shown because too many files have changed in this diff Show more