Skip to content

Commit

Permalink
Merge branch 'main' into mpt-test
Browse files Browse the repository at this point in the history
  • Loading branch information
pratiksharma23 committed Feb 24, 2024
2 parents fbd57e5 + 9a38aed commit 208f131
Show file tree
Hide file tree
Showing 43 changed files with 1,839 additions and 1,386 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# 🎭 Playwright

[![npm version](https://img.shields.io/npm/v/playwright.svg)](https://www.npmjs.com/package/playwright) <!-- GEN:chromium-version-badge -->[![Chromium version](https://img.shields.io/badge/chromium-122.0.6261.57-blue.svg?logo=google-chrome)](https://www.chromium.org/Home)<!-- GEN:stop --> <!-- GEN:firefox-version-badge -->[![Firefox version](https://img.shields.io/badge/firefox-122.0-blue.svg?logo=firefoxbrowser)](https://www.mozilla.org/en-US/firefox/new/)<!-- GEN:stop --> <!-- GEN:webkit-version-badge -->[![WebKit version](https://img.shields.io/badge/webkit-17.4-blue.svg?logo=safari)](https://webkit.org/)<!-- GEN:stop -->
[![npm version](https://img.shields.io/npm/v/playwright.svg)](https://www.npmjs.com/package/playwright) <!-- GEN:chromium-version-badge -->[![Chromium version](https://img.shields.io/badge/chromium-123.0.6312.4-blue.svg?logo=google-chrome)](https://www.chromium.org/Home)<!-- GEN:stop --> <!-- GEN:firefox-version-badge -->[![Firefox version](https://img.shields.io/badge/firefox-123.0-blue.svg?logo=firefoxbrowser)](https://www.mozilla.org/en-US/firefox/new/)<!-- GEN:stop --> <!-- GEN:webkit-version-badge -->[![WebKit version](https://img.shields.io/badge/webkit-17.4-blue.svg?logo=safari)](https://webkit.org/)<!-- GEN:stop -->

## [Documentation](https://playwright.dev) | [API reference](https://playwright.dev/docs/api/class-playwright)

Playwright is a framework for Web Testing and Automation. It allows testing [Chromium](https://www.chromium.org/Home), [Firefox](https://www.mozilla.org/en-US/firefox/new/) and [WebKit](https://webkit.org/) with a single API. Playwright is built to enable cross-browser web automation that is **ever-green**, **capable**, **reliable** and **fast**.

| | Linux | macOS | Windows |
| :--- | :---: | :---: | :---: |
| Chromium <!-- GEN:chromium-version -->122.0.6261.57<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| Chromium <!-- GEN:chromium-version -->123.0.6312.4<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| WebKit <!-- GEN:webkit-version -->17.4<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| Firefox <!-- GEN:firefox-version -->122.0<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| Firefox <!-- GEN:firefox-version -->123.0<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |

Headless execution is supported for all browsers on all platforms. Check out [system requirements](https://playwright.dev/docs/intro#system-requirements) for details.

Expand Down
2 changes: 1 addition & 1 deletion browser_patches/firefox/UPSTREAM_CONFIG.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
REMOTE_URL="https://github.com/mozilla/gecko-dev"
BASE_BRANCH="release"
BASE_REVISION="7ab3cc0103090dd7bfa02e072a529b9fc784ab4e"
BASE_REVISION="a32b8662993085139ac91212a297123b632fc1c0"
10 changes: 10 additions & 0 deletions browser_patches/firefox/juggler/Helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ class Helper {
return allBrowsingContexts;
}

awaitTopic(topic) {
return new Promise(resolve => {
const listener = () => {
Services.obs.removeObserver(listener, topic);
resolve();
}
Services.obs.addObserver(listener, topic);
});
}

toProtocolNavigationId(loadIdentifier) {
return `nav-${loadIdentifier}`;
}
Expand Down
9 changes: 0 additions & 9 deletions browser_patches/firefox/juggler/NetworkObserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,13 +366,6 @@ class NetworkRequest {
return;
}

const browserContext = pageNetwork._target.browserContext();
if (browserContext.crossProcessCookie.settings.onlineOverride === 'offline') {
// Implement offline.
this.abort(Cr.NS_ERROR_OFFLINE);
return;
}

// Ok, so now we have intercepted the request, let's issue onRequest.
// If interception has been disabled while we were intercepting, resume and forget.
const interceptionEnabled = this._shouldIntercept();
Expand Down Expand Up @@ -462,8 +455,6 @@ class NetworkRequest {
const browserContext = pageNetwork._target.browserContext();
if (browserContext.requestInterceptionEnabled)
return true;
if (browserContext.crossProcessCookie.settings.onlineOverride === 'offline')
return true;
return false;
}

Expand Down
12 changes: 12 additions & 0 deletions browser_patches/firefox/juggler/TargetRegistry.js
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,11 @@ class PageTarget {
this.updateColorSchemeOverride(browsingContext);
this.updateReducedMotionOverride(browsingContext);
this.updateForcedColorsOverride(browsingContext);
this.updateForceOffline(browsingContext);
}

updateForceOffline(browsingContext = undefined) {
(browsingContext || this._linkedBrowser.browsingContext).forceOffline = this._browserContext.forceOffline;
}

updateTouchOverride(browsingContext = undefined) {
Expand Down Expand Up @@ -829,6 +834,7 @@ class BrowserContext {
this.defaultUserAgent = null;
this.defaultPlatform = null;
this.touchOverride = false;
this.forceOffline = false;
this.colorScheme = 'none';
this.forcedColors = 'no-override';
this.reducedMotion = 'none';
Expand Down Expand Up @@ -924,6 +930,12 @@ class BrowserContext {
page.updateTouchOverride();
}

setForceOffline(forceOffline) {
this.forceOffline = forceOffline;
for (const page of this.pages)
page.updateForceOffline();
}

async setDefaultViewport(viewport) {
this.defaultViewportSize = viewport ? viewport.viewportSize : undefined;
this.deviceScaleFactor = viewport ? viewport.deviceScaleFactor : undefined;
Expand Down
8 changes: 0 additions & 8 deletions browser_patches/firefox/juggler/content/PageAgent.js
Original file line number Diff line number Diff line change
Expand Up @@ -461,16 +461,8 @@ class PageAgent {
}

async _dispatchKeyEvent({type, keyCode, code, key, repeat, location, text}) {
if (code === 'OSLeft')
code = 'MetaLeft';
else if (code === 'OSRight')
code = 'MetaRight';
const frame = this._frameTree.mainFrame();
const tip = frame.textInputProcessor();
if (key === 'Meta' && Services.appinfo.OS !== 'Darwin')
key = 'OS';
else if (key === 'OS' && Services.appinfo.OS === 'Darwin')
key = 'Meta';
let keyEvent = new (frame.domWindow().KeyboardEvent)("", {
key,
code,
Expand Down
9 changes: 0 additions & 9 deletions browser_patches/firefox/juggler/content/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,6 @@ function initialize(browsingContext, docShell, actor) {
}
},

onlineOverride: (onlineOverride) => {
if (!onlineOverride) {
docShell.onlineOverride = Ci.nsIDocShell.ONLINE_OVERRIDE_NONE;
return;
}
docShell.onlineOverride = onlineOverride === 'online' ?
Ci.nsIDocShell.ONLINE_OVERRIDE_ONLINE : Ci.nsIDocShell.ONLINE_OVERRIDE_OFFLINE;
},

bypassCSP: (bypassCSP) => {
docShell.bypassCSPEnabled = bypassCSP;
},
Expand Down
3 changes: 2 additions & 1 deletion browser_patches/firefox/juggler/protocol/BrowserHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ class BrowserHandler {
}

async ['Browser.setOnlineOverride']({browserContextId, override}) {
await this._targetRegistry.browserContextForId(browserContextId).applySetting('onlineOverride', nullToUndefined(override));
const forceOffline = override === 'offline';
await this._targetRegistry.browserContextForId(browserContextId).setForceOffline(forceOffline);
}

async ['Browser.setColorScheme']({browserContextId, colorScheme}) {
Expand Down
9 changes: 8 additions & 1 deletion browser_patches/firefox/juggler/protocol/PageHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,9 @@ class PageHandler {
this._pageTarget._linkedBrowser.scrollRectIntoViewIfNeeded(x, y, 0, 0);
// 2. Get element's bounding box in the browser after the scroll is completed.
const boundingBox = this._pageTarget._linkedBrowser.getBoundingClientRect();
// 3. Make sure compositor is flushed after scrolling.
if (win.windowUtils.flushApzRepaints())
await helper.awaitTopic('apz-repaints-flushed');

const watcher = new EventWatcher(this._pageEventSink, types, this._pendingEventWatchers);
const promises = [];
Expand Down Expand Up @@ -608,7 +611,7 @@ class PageHandler {
const lineOrPageDeltaX = deltaX > 0 ? Math.floor(deltaX) : Math.ceil(deltaX);
const lineOrPageDeltaY = deltaY > 0 ? Math.floor(deltaY) : Math.ceil(deltaY);

await this._pageTarget.activateAndRun(() => {
await this._pageTarget.activateAndRun(async () => {
this._pageTarget.ensureContextMenuClosed();

// 1. Scroll element to the desired location first; the coordinates are relative to the element.
Expand All @@ -617,6 +620,10 @@ class PageHandler {
const boundingBox = this._pageTarget._linkedBrowser.getBoundingClientRect();

const win = this._pageTarget._window;
// 3. Make sure compositor is flushed after scrolling.
if (win.windowUtils.flushApzRepaints())
await helper.awaitTopic('apz-repaints-flushed');

win.windowUtils.sendWheelEvent(
x + boundingBox.left,
y + boundingBox.top,
Expand Down
Loading

0 comments on commit 208f131

Please sign in to comment.