commit 7bfaf2751e634e3d5cde061cf20027c46420488b parent 70fb25dd20510509c0603d579e78822fb8278923 Author: Nicolas Chevobbe <nchevobbe@mozilla.com> Date: Fri, 17 Oct 2025 11:59:51 +0000 Bug 1994970 - [devtools] Migrate `content.document.defaultView` to `content`. r=devtools-reviewers,bomsy. `content.document.defaultView` returns the same thing as `content`, so let's use the shortest version. Differential Revision: https://phabricator.services.mozilla.com/D269023 Diffstat:
6 files changed, 19 insertions(+), 20 deletions(-)
diff --git a/devtools/client/inspector/test/shared-head.js b/devtools/client/inspector/test/shared-head.js @@ -480,7 +480,7 @@ async function getComputedStyleProperty(selector, pseudo, propName) { [selector, pseudo, propName], (selectorChild, pseudoChild, propNameChild) => { const element = content.document.querySelector(selectorChild); - return content.document.defaultView + return content .getComputedStyle(element, pseudoChild) .getPropertyValue(propNameChild); } @@ -512,7 +512,7 @@ async function waitForComputedStyleProperty( (selectorChild, pseudoChild, propNameChild, expectedChild) => { const element = content.document.querySelector(selectorChild); return ContentTaskUtils.waitForCondition(() => { - const value = content.document.defaultView + const value = content .getComputedStyle(element, pseudoChild) .getPropertyValue(propNameChild); return value === expectedChild; diff --git a/devtools/client/responsive/test/browser/browser_touch_does_not_trigger_hover_states.js b/devtools/client/responsive/test/browser/browser_touch_does_not_trigger_hover_states.js @@ -40,10 +40,9 @@ async function testButtonHoverState(ui, expected) { content ); button = content.document.querySelector("button"); - const win = content.document.defaultView; is( - win.getComputedStyle(button).getPropertyValue("background-color"), + content.getComputedStyle(button).getPropertyValue("background-color"), contentExpected, `Button background color is ${contentExpected}.` ); @@ -65,11 +64,10 @@ async function testDropDownHoverState(ui, expected) { { type: "mousemove", isSynthesized: false }, content ); - const win = content.document.defaultView; const menuItems = content.document.querySelector(".menu-items-list"); is( - win.getComputedStyle(menuItems).getPropertyValue("display"), + content.getComputedStyle(menuItems).getPropertyValue("display"), contentExpected, `Menu items is display: ${contentExpected}.` ); diff --git a/devtools/client/responsive/test/browser/browser_touch_event_should_bubble.js b/devtools/client/responsive/test/browser/browser_touch_event_should_bubble.js @@ -29,8 +29,9 @@ addRDMTask(TEST_URL, async function ({ ui }) { ); await touchStartPromise; - const win = content.document.defaultView; - const bg = win.getComputedStyle(span).getPropertyValue("background-color"); + const bg = content + .getComputedStyle(span) + .getPropertyValue("background-color"); is( bg, diff --git a/devtools/client/responsive/test/browser/browser_touch_pointerevents.js b/devtools/client/responsive/test/browser/browser_touch_pointerevents.js @@ -65,8 +65,9 @@ async function testPointerEvents(ui) { content ); - const win = content.document.defaultView; - const bg = win.getComputedStyle(div).getPropertyValue("background-color"); + const bg = content + .getComputedStyle(div) + .getPropertyValue("background-color"); is( bg, diff --git a/devtools/client/responsive/test/browser/browser_touch_simulation.js b/devtools/client/responsive/test/browser/browser_touch_simulation.js @@ -100,19 +100,19 @@ async function testWithNoTouch(ui) { // Assuming that this test runs on devices having no touch screen device. ok( - !content.document.defaultView.matchMedia("(pointer: coarse)").matches, + !content.matchMedia("(pointer: coarse)").matches, "pointer: coarse shouldn't be matched" ); ok( - !content.document.defaultView.matchMedia("(hover: none)").matches, + !content.matchMedia("(hover: none)").matches, "hover: none shouldn't be matched" ); ok( - !content.document.defaultView.matchMedia("(any-pointer: coarse)").matches, + !content.matchMedia("(any-pointer: coarse)").matches, "any-pointer: coarse shouldn't be matched" ); ok( - !content.document.defaultView.matchMedia("(any-hover: none)").matches, + !content.matchMedia("(any-hover: none)").matches, "any-hover: none shouldn't be matched" ); }); @@ -192,19 +192,19 @@ async function testWithTouch(ui) { ); ok( - content.document.defaultView.matchMedia("(pointer: coarse)").matches, + content.matchMedia("(pointer: coarse)").matches, "pointer: coarse should be matched" ); ok( - content.document.defaultView.matchMedia("(hover: none)").matches, + content.matchMedia("(hover: none)").matches, "hover: none should be matched" ); ok( - content.document.defaultView.matchMedia("(any-pointer: coarse)").matches, + content.matchMedia("(any-pointer: coarse)").matches, "any-pointer: coarse should be matched" ); ok( - content.document.defaultView.matchMedia("(any-hover: none)").matches, + content.matchMedia("(any-hover: none)").matches, "any-hover: none should be matched" ); }); diff --git a/devtools/client/responsive/test/browser/browser_viewport_fallback_width.js b/devtools/client/responsive/test/browser/browser_viewport_fallback_width.js @@ -45,8 +45,7 @@ async function testICBWidth(ui) { await EventUtils.synthesizeClick(innerDiv); await mousedown; - const win = content.document.defaultView; - const bg = win.getComputedStyle(innerDiv).getPropertyValue("color"); + const bg = content.getComputedStyle(innerDiv).getPropertyValue("color"); is(bg, "rgb(0, 128, 0)", "inner div's background color changed to green."); });