chromium-bidi
Advanced tools
Comparing version 0.9.0 to 0.9.1
@@ -345,13 +345,35 @@ "use strict"; | ||
} | ||
async #getFrameOffset() { | ||
// https://github.com/w3c/webdriver/pull/1847 proposes dispatching events from | ||
// the top-level browsing context. This implementation dispatches it on the top-most | ||
// same-target frame, which is not top-level one in case of OOPiF. | ||
// TODO: switch to the top-level browsing context. | ||
try { | ||
const { backendNodeId } = await this.#context.cdpTarget.cdpClient.sendCommand('DOM.getFrameOwner', { frameId: this.#context.id }); | ||
const { model: frameBoxModel } = await this.#context.cdpTarget.cdpClient.sendCommand('DOM.getBoxModel', { | ||
backendNodeId, | ||
}); | ||
return { x: frameBoxModel.content[0], y: frameBoxModel.content[1] }; | ||
} | ||
catch (e) { | ||
if (e.code === -32000 && | ||
e.message === 'Frame with the given id does not belong to the target.') { | ||
// Heuristic to determine if the browsing context is top-level in the target session. | ||
return { x: 0, y: 0 }; | ||
} | ||
throw e; | ||
} | ||
} | ||
async #getCoordinateFromOrigin(origin, offsetX, offsetY, startX, startY) { | ||
let targetX; | ||
let targetY; | ||
const frameOffset = await this.#getFrameOffset(); | ||
switch (origin) { | ||
case 'viewport': | ||
targetX = offsetX; | ||
targetY = offsetY; | ||
targetX = offsetX + frameOffset.x; | ||
targetY = offsetY + frameOffset.y; | ||
break; | ||
case 'pointer': | ||
targetX = startX + offsetX; | ||
targetY = startY + offsetY; | ||
targetX = startX + offsetX + frameOffset.x; | ||
targetY = startY + offsetY + frameOffset.y; | ||
break; | ||
@@ -361,4 +383,4 @@ default: { | ||
// SAFETY: These can never be special numbers. | ||
targetX = posX + offsetX; | ||
targetY = posY + offsetY; | ||
targetX = posX + offsetX + frameOffset.x; | ||
targetY = posY + offsetY + frameOffset.y; | ||
break; | ||
@@ -365,0 +387,0 @@ } |
@@ -57,9 +57,9 @@ /** | ||
count: number; | ||
"__#90920@#x": number; | ||
"__#90920@#y": number; | ||
"__#90920@#time": number; | ||
"__#90943@#x": number; | ||
"__#90943@#y": number; | ||
"__#90943@#time": number; | ||
compare(context: any): boolean; | ||
}; | ||
"__#90920@#DOUBLE_CLICK_TIME_MS": number; | ||
"__#90920@#MAX_DOUBLE_CLICK_RADIUS": number; | ||
"__#90943@#DOUBLE_CLICK_TIME_MS": number; | ||
"__#90943@#MAX_DOUBLE_CLICK_RADIUS": number; | ||
}; | ||
@@ -66,0 +66,0 @@ setClickCount(button: number, context: InstanceType<typeof PointerSource.ClickContext>): number; |
@@ -185,3 +185,5 @@ "use strict"; | ||
const { result } = await this.cdpClient.sendCommand('Runtime.callFunctionOn', { | ||
functionDeclaration: String((remoteObject) => String(remoteObject)), | ||
functionDeclaration: String( | ||
// eslint-disable-next-line @typescript-eslint/no-base-to-string | ||
(remoteObject) => String(remoteObject)), | ||
awaitPromise: false, | ||
@@ -188,0 +190,0 @@ arguments: [cdpRemoteObject], |
@@ -342,13 +342,35 @@ /** | ||
} | ||
async #getFrameOffset() { | ||
// https://github.com/w3c/webdriver/pull/1847 proposes dispatching events from | ||
// the top-level browsing context. This implementation dispatches it on the top-most | ||
// same-target frame, which is not top-level one in case of OOPiF. | ||
// TODO: switch to the top-level browsing context. | ||
try { | ||
const { backendNodeId } = await this.#context.cdpTarget.cdpClient.sendCommand('DOM.getFrameOwner', { frameId: this.#context.id }); | ||
const { model: frameBoxModel } = await this.#context.cdpTarget.cdpClient.sendCommand('DOM.getBoxModel', { | ||
backendNodeId, | ||
}); | ||
return { x: frameBoxModel.content[0], y: frameBoxModel.content[1] }; | ||
} | ||
catch (e) { | ||
if (e.code === -32000 && | ||
e.message === 'Frame with the given id does not belong to the target.') { | ||
// Heuristic to determine if the browsing context is top-level in the target session. | ||
return { x: 0, y: 0 }; | ||
} | ||
throw e; | ||
} | ||
} | ||
async #getCoordinateFromOrigin(origin, offsetX, offsetY, startX, startY) { | ||
let targetX; | ||
let targetY; | ||
const frameOffset = await this.#getFrameOffset(); | ||
switch (origin) { | ||
case 'viewport': | ||
targetX = offsetX; | ||
targetY = offsetY; | ||
targetX = offsetX + frameOffset.x; | ||
targetY = offsetY + frameOffset.y; | ||
break; | ||
case 'pointer': | ||
targetX = startX + offsetX; | ||
targetY = startY + offsetY; | ||
targetX = startX + offsetX + frameOffset.x; | ||
targetY = startY + offsetY + frameOffset.y; | ||
break; | ||
@@ -358,4 +380,4 @@ default: { | ||
// SAFETY: These can never be special numbers. | ||
targetX = posX + offsetX; | ||
targetY = posY + offsetY; | ||
targetX = posX + offsetX + frameOffset.x; | ||
targetY = posY + offsetY + frameOffset.y; | ||
break; | ||
@@ -362,0 +384,0 @@ } |
@@ -57,9 +57,9 @@ /** | ||
count: number; | ||
"__#90920@#x": number; | ||
"__#90920@#y": number; | ||
"__#90920@#time": number; | ||
"__#90943@#x": number; | ||
"__#90943@#y": number; | ||
"__#90943@#time": number; | ||
compare(context: any): boolean; | ||
}; | ||
"__#90920@#DOUBLE_CLICK_TIME_MS": number; | ||
"__#90920@#MAX_DOUBLE_CLICK_RADIUS": number; | ||
"__#90943@#DOUBLE_CLICK_TIME_MS": number; | ||
"__#90943@#MAX_DOUBLE_CLICK_RADIUS": number; | ||
}; | ||
@@ -66,0 +66,0 @@ setClickCount(button: number, context: InstanceType<typeof PointerSource.ClickContext>): number; |
@@ -182,3 +182,5 @@ import { ChromiumBidi, NoSuchHandleException, } from '../../../protocol/protocol.js'; | ||
const { result } = await this.cdpClient.sendCommand('Runtime.callFunctionOn', { | ||
functionDeclaration: String((remoteObject) => String(remoteObject)), | ||
functionDeclaration: String( | ||
// eslint-disable-next-line @typescript-eslint/no-base-to-string | ||
(remoteObject) => String(remoteObject)), | ||
awaitPromise: false, | ||
@@ -185,0 +187,0 @@ arguments: [cdpRemoteObject], |
{ | ||
"name": "chromium-bidi", | ||
"version": "0.9.0", | ||
"version": "0.9.1", | ||
"description": "An implementation of the WebDriver BiDi protocol for Chromium implemented as a JavaScript layer translating between BiDi and CDP, running inside a Chrome tab.", | ||
@@ -164,9 +164,9 @@ "scripts": { | ||
"@actions/core": "1.11.1", | ||
"@eslint/compat": "1.2.1", | ||
"@eslint/compat": "1.2.2", | ||
"@eslint/eslintrc": "3.1.0", | ||
"@eslint/js": "9.13.0", | ||
"@eslint/js": "9.14.0", | ||
"@puppeteer/browsers": "2.4.0", | ||
"@rollup/plugin-alias": "5.1.1", | ||
"@rollup/plugin-node-resolve": "15.3.0", | ||
"@rollup/wasm-node": "4.24.0", | ||
"@rollup/wasm-node": "4.24.3", | ||
"@types/chai": "4.3.17", | ||
@@ -176,9 +176,9 @@ "@types/chai-as-promised": "7.1.8", | ||
"@types/mocha": "10.0.9", | ||
"@types/node": "20.16.13", | ||
"@types/node": "20.17.6", | ||
"@types/sinon": "17.0.3", | ||
"@types/websocket": "1.0.10", | ||
"@types/ws": "8.5.12", | ||
"@types/ws": "8.5.13", | ||
"@types/yargs": "17.0.33", | ||
"@typescript-eslint/eslint-plugin": "8.10.0", | ||
"@typescript-eslint/parser": "8.10.0", | ||
"@typescript-eslint/eslint-plugin": "8.12.2", | ||
"@typescript-eslint/parser": "8.12.2", | ||
"chai": "4.5.0", | ||
@@ -196,16 +196,16 @@ "chai-as-promised": "7.1.2", | ||
"globals": "15.11.0", | ||
"gts": "6.0.0", | ||
"mocha": "10.7.3", | ||
"gts": "6.0.2", | ||
"mocha": "10.8.2", | ||
"pkg-dir": "8.0.0", | ||
"prettier": "3.3.3", | ||
"rimraf": "6.0.1", | ||
"rollup": "4.24.0", | ||
"rollup": "4.24.3", | ||
"rollup-plugin-license": "3.5.3", | ||
"selenium-webdriver": "4.25.0", | ||
"selenium-webdriver": "4.26.0", | ||
"semver": "7.6.3", | ||
"sinon": "19.0.2", | ||
"source-map-support": "0.5.21", | ||
"tslib": "2.8.0", | ||
"tslib": "2.8.1", | ||
"typescript": "5.6.3", | ||
"webdriverio": "9.2.1", | ||
"webdriverio": "9.2.8", | ||
"websocket": "1.0.35", | ||
@@ -212,0 +212,0 @@ "wireit": "0.14.9", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11095372
170469