Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

browser(firefox): another way to report elements without layout object (#2597)

Dmitry Gozmanab5f5c8b782f
diff --git a/browser_patches/firefox/BUILD_NUMBER b/browser_patches/firefox/BUILD_NUMBER
index 0a75ff7619..5f2f16bfff 100644
--- a/browser_patches/firefox/BUILD_NUMBER
+++ b/browser_patches/firefox/BUILD_NUMBER
@@ -1 +1 @@
-1110
+1111
diff --git a/browser_patches/firefox/juggler/content/PageAgent.js b/browser_patches/firefox/juggler/content/PageAgent.js
index 4c759767f7..278b5da4ce 100644
--- a/browser_patches/firefox/juggler/content/PageAgent.js
+++ b/browser_patches/firefox/juggler/content/PageAgent.js
@@ -621,23 +621,12 @@ class PageAgent {
const unsafeObject = this._frameData.get(frame).unsafeObject(objectId);
if (!unsafeObject.isConnected)
throw new Error('Node is detached from document');
- if (!unsafeObject.ownerDocument || !unsafeObject.ownerDocument.defaultView)
- throw new Error('Node is detached from document');
- const element = unsafeObject.nodeType === 1 ? unsafeObject : unsafeObject.parentElement;
- if (!element)
- throw new Error('Node is detached from document');
- const style = unsafeObject.ownerDocument.defaultView.getComputedStyle(element);
- if (!style || style.visibility === 'hidden')
- throw new Error('Node is not visible');
- const bounds = element.getBoundingClientRect();
- if (bounds.width <= 0 || bounds.height <= 0)
- throw new Error('Node is not visible');
if (!rect)
rect = { x: -1, y: -1, width: -1, height: -1};
if (unsafeObject.scrollRectIntoViewIfNeeded)
unsafeObject.scrollRectIntoViewIfNeeded(rect.x, rect.y, rect.width, rect.height);
else
- throw new Error('Node type does not support scrollRectIntoViewIfNeeded');
+ throw new Error('Node does not have a layout object');
}
_getNodeBoundingBox(unsafeObject) {
diff --git a/browser_patches/firefox/patches/bootstrap.diff b/browser_patches/firefox/patches/bootstrap.diff
index d6293f2be1..bff2ecd49d 100644
--- a/browser_patches/firefox/patches/bootstrap.diff
+++ b/browser_patches/firefox/patches/bootstrap.diff
@@ -671,7 +671,7 @@ index da9d56e843a2c762dc7d5527712cdd3d30418f7f..ea9d962513dfc02682d5dfd543dd72ba
}
diff --git a/dom/base/nsINode.cpp b/dom/base/nsINode.cpp
-index 7c0d4bd261bf053c7cab4091522dc1e52118eba1..9af7b44c443955dc6355197bb94f65c229d165a3 100644
+index 7c0d4bd261bf053c7cab4091522dc1e52118eba1..e320e6bfb0402eb07ae53272264278bad9638519 100644
--- a/dom/base/nsINode.cpp
+++ b/dom/base/nsINode.cpp
@@ -1260,6 +1260,48 @@ void nsINode::GetBoxQuadsFromWindowOrigin(const BoxQuadOptions& aOptions,
@@ -684,19 +684,19 @@ index 7c0d4bd261bf053c7cab4091522dc1e52118eba1..9af7b44c443955dc6355197bb94f65c2
+ aRv = NS_ERROR_UNEXPECTED;
+ nsCOMPtr<Document> document = OwnerDoc();
+ if (!document) {
-+ return;
++ return aRv.ThrowNotFoundError("Node is detached from document");
+ }
+ PresShell* presShell = document->GetPresShell();
+ if (!presShell) {
-+ return;
++ return aRv.ThrowNotFoundError("Node is detached from document");
+ }
+ if (!IsContent()) {
-+ return;
++ return aRv.ThrowNotFoundError("Node does not have a layout object");
+ }
+ aRv = NS_OK;
+ nsIFrame* primaryFrame = AsContent()->GetPrimaryFrame(FlushType::Frames);
-+ if (!primaryFrame){
-+ return;
++ if (!primaryFrame) {
++ return aRv.ThrowNotFoundError("Node does not have a layout object");
+ }
+ nsRect rect;
+ if (x == -1 && y == -1 && w == -1 && h == -1) {