mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 15:23:51 +00:00
Bug 1625417 - [cdp] Use number as nodeId for DOM methods r=webdriver-reviewers,jdescottes
Use a number as nodeId instead of a UUID string as per CDP spec. Also fixed tests expecting number to be an invalid type and string to be valid instead. Differential Revision: https://phabricator.services.mozilla.com/D167316
This commit is contained in:
parent
770d68823c
commit
22ee5824f9
@ -79,7 +79,7 @@ export class DOM extends ContentProcessDomain {
|
||||
|
||||
const node = {
|
||||
nodeId: debuggerObj.nodeId,
|
||||
backendNodeId: debuggerObj.nodeId,
|
||||
backendNodeId: debuggerObj.backendNodeId,
|
||||
nodeType: unsafeObj.nodeType,
|
||||
nodeName: unsafeObj.nodeName,
|
||||
localName: unsafeObj.localName,
|
||||
@ -209,9 +209,8 @@ export class DOM extends ContentProcessDomain {
|
||||
const { backendNodeId, executionContextId } = options;
|
||||
|
||||
// Until nodeId is supported force usage of the backendNodeId
|
||||
// Bug 1625417 - CDP expects the id as number
|
||||
if (!["string"].includes(typeof backendNodeId)) {
|
||||
throw new TypeError("backendNodeId: string value expected");
|
||||
if (!["number"].includes(typeof backendNodeId)) {
|
||||
throw new TypeError("backendNodeId: number value expected");
|
||||
}
|
||||
if (!["undefined", "number"].includes(typeof executionContextId)) {
|
||||
throw new TypeError("executionContextId: integer value expected");
|
||||
|
@ -25,6 +25,10 @@ function uuid() {
|
||||
.slice(1, -1);
|
||||
}
|
||||
|
||||
function randomInt() {
|
||||
return crypto.getRandomValues(new Uint32Array(1))[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* This class represent a debuggable context onto which we can evaluate Javascript.
|
||||
* This is typically a document, but it could also be a worker, an add-on, ... or
|
||||
@ -104,7 +108,7 @@ export class ExecutionContext {
|
||||
debuggerObj instanceof Debugger.Object &&
|
||||
Node.isInstance(debuggerObj.unsafeDereference())
|
||||
) {
|
||||
debuggerObj.nodeId = uuid();
|
||||
debuggerObj.nodeId = randomInt();
|
||||
// We do not differentiate between backendNodeId and nodeId (yet)
|
||||
debuggerObj.backendNodeId = debuggerObj.nodeId;
|
||||
}
|
||||
|
@ -6,8 +6,7 @@
|
||||
add_task(async function backendNodeIdInvalidTypes({ client }) {
|
||||
const { DOM } = client;
|
||||
|
||||
// Bug 1625417 - CDP expects the id as number
|
||||
for (const backendNodeId of [null, true, 1, /* "foo", */ [], {}]) {
|
||||
for (const backendNodeId of [null, true, "foo", [], {}]) {
|
||||
let errorThrown = "";
|
||||
try {
|
||||
await DOM.resolveNode({ backendNodeId });
|
||||
@ -15,7 +14,7 @@ add_task(async function backendNodeIdInvalidTypes({ client }) {
|
||||
errorThrown = e.message;
|
||||
}
|
||||
ok(
|
||||
errorThrown.match(/backendNodeId: string value expected/),
|
||||
errorThrown.match(/backendNodeId: number value expected/),
|
||||
`Fails for invalid type: ${backendNodeId}`
|
||||
);
|
||||
}
|
||||
@ -26,7 +25,7 @@ add_task(async function backendNodeIdInvalidValue({ client }) {
|
||||
|
||||
let errorThrown = "";
|
||||
try {
|
||||
await DOM.resolveNode({ backendNodeId: "-1" });
|
||||
await DOM.resolveNode({ backendNodeId: -1 });
|
||||
} catch (e) {
|
||||
errorThrown = e.message;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user