Skip to content

Commit

Permalink
feat: wip dpr
Browse files Browse the repository at this point in the history
  • Loading branch information
OrKoN committed Oct 12, 2023
1 parent d07ae7a commit 5a86cd7
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/bidiMapper/domains/context/BrowsingContextImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ export class BrowsingContextImpl {

async setViewport(
viewport: BrowsingContext.Viewport | null,
devicePixelRatio: number | null
devicePixelRatio?: number | null
) {
if (viewport === null && devicePixelRatio === null) {
await this.#cdpTarget.cdpClient.sendCommand(
Expand Down
6 changes: 1 addition & 5 deletions src/protocol-parser/webdriver-bidi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -616,10 +616,7 @@ export namespace BrowsingContext {
z.object({
context: BrowsingContext.BrowsingContextSchema,
viewport: z.union([BrowsingContext.ViewportSchema, z.null()]),
devicePixelRatio: z.union([
BrowsingContext.DevicePixelRatioSchema,
z.null(),
]),
devicePixelRatio: z.union([z.number().gt(0), z.null()]).optional(),
})
);
}
Expand All @@ -630,7 +627,6 @@ export namespace BrowsingContext {
height: JsUintSchema,
})
);
export const DevicePixelRatioSchema = z.lazy(() => z.number().gt(0));
}
export namespace BrowsingContext {
export const ContextCreatedSchema = z.lazy(() =>
Expand Down
2 changes: 1 addition & 1 deletion src/protocol/webdriver-bidi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ export namespace BrowsingContext {
export type SetViewportParameters = {
context: BrowsingContext.BrowsingContext;
viewport: BrowsingContext.Viewport | null;
devicePixelRatio: number | null;
devicePixelRatio?: number | null;
};
}
export namespace BrowsingContext {
Expand Down
6 changes: 4 additions & 2 deletions tests/browsing_context/test_set_viewport.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ async def test_set_viewport(websocket, context_id, html):
"viewport": {
"width": 300,
"height": 300,
}
},
"devicePixelRatio": None
}
})

Expand Down Expand Up @@ -118,6 +119,7 @@ async def test_set_viewport_unsupported(websocket, context_id, html, width,
"viewport": {
"width": width,
"height": height,
}
},
"devicePixelRatio": None
}
})

0 comments on commit 5a86cd7

Please sign in to comment.