Diff
Modified: trunk/LayoutTests/ChangeLog (268715 => 268716)
--- trunk/LayoutTests/ChangeLog 2020-10-20 06:40:43 UTC (rev 268715)
+++ trunk/LayoutTests/ChangeLog 2020-10-20 08:00:55 UTC (rev 268716)
@@ -1,3 +1,15 @@
+2020-10-20 Philippe Normand <pnorm...@igalia.com> and Pavel Feldman <pavel.feld...@gmail.com>
+
+ Web Inspector: Add setScreenSizeOverride API to the Page agent
+ https://bugs.webkit.org/show_bug.cgi?id=213242
+
+ Reviewed by Devin Rousso.
+
+ * TestExpectations:
+ * inspector/page/setScreenSizeOverride.html: Added.
+ * platform/glib/TestExpectations:
+ * platform/glib/inspector/page/setScreenSizeOverride-expected.txt: Added.
+
2020-10-19 Sihui Liu <sihui_...@apple.com>
Import speech tests from WPT
Modified: trunk/LayoutTests/TestExpectations (268715 => 268716)
--- trunk/LayoutTests/TestExpectations 2020-10-20 06:40:43 UTC (rev 268715)
+++ trunk/LayoutTests/TestExpectations 2020-10-20 08:00:55 UTC (rev 268716)
@@ -76,6 +76,7 @@
editing/pasteboard/mac [ Skip ]
fast/media/ios [ Skip ]
fast/dom/Range/mac [ Skip ]
+inspector/page/setScreenSizeOverride.html [ Skip ]
# Requires async overflow scrolling
compositing/shared-backing/overflow-scroll [ Skip ]
Added: trunk/LayoutTests/inspector/page/setScreenSizeOverride.html (0 => 268716)
--- trunk/LayoutTests/inspector/page/setScreenSizeOverride.html (rev 0)
+++ trunk/LayoutTests/inspector/page/setScreenSizeOverride.html 2020-10-20 08:00:55 UTC (rev 268716)
@@ -0,0 +1,56 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<style>
+@media only screen and (max-device-width: 1000px) {
+ body {
+ color: red;
+ }
+}
+</style>
+<script>
+function test() {
+ let suite = InspectorTest.createAsyncSuite("Page.setScreenSizeOverride");
+
+ suite.addTestCase({
+ name: "ScreenSizeOverrideOverride",
+ description: "Verify that the inspector can override the screen size.",
+ async test() {
+ let originalScreenWidth = await InspectorTest.evaluateInPage(`window.screen.width`);
+ let originalScreenHeight = await InspectorTest.evaluateInPage(`window.screen.height`);
+
+ let currentBackgroundColor = await InspectorTest.evaluateInPage("getComputedStyle(document.body).color");
+ InspectorTest.expectEqual(currentBackgroundColor, "rgb(0, 0, 0)", "Body should be white.");
+
+ InspectorTest.log("Overriding screen size to 1000x500");
+ await PageAgent.setScreenSizeOverride(1000, 500);
+ await InspectorTest.evaluateInPage(`location.reload()`);
+
+ let newScreenWidth = await InspectorTest.evaluateInPage(`window.screen.width`);
+ InspectorTest.expectEqual(newScreenWidth, 1000, "Default screen width should be 1000.");
+ let newScreenHeight = await InspectorTest.evaluateInPage(`window.screen.height`);
+ InspectorTest.expectEqual(newScreenHeight, 500, "Default screen height should be 500.");
+
+ let newBackgroundColor = await InspectorTest.evaluateInPage("getComputedStyle(document.body).color");
+ InspectorTest.expectEqual(newBackgroundColor, "rgb(255, 0, 0)", "Body should be red.");
+
+ InspectorTest.log("Removing screen size override");
+ await PageAgent.setScreenSizeOverride();
+ await InspectorTest.evaluateInPage(`location.reload()`);
+
+ newScreenWidth = await InspectorTest.evaluateInPage(`window.screen.width`);
+ InspectorTest.expectEqual(newScreenWidth, originalScreenWidth, "Screen width override should be removed.");
+ newScreenHeight = await InspectorTest.evaluateInPage(`window.screen.height`);
+ InspectorTest.expectEqual(newScreenHeight, originalScreenHeight, "Screen height override should be removed.");
+ }
+ });
+
+ WI.domManager.requestDocument((node) => {
+ suite.runTestCasesAndFinish();
+ });
+}
+</script>
+</head>
+<body _onload_="runTest()"/>
+</html>
Modified: trunk/LayoutTests/platform/glib/TestExpectations (268715 => 268716)
--- trunk/LayoutTests/platform/glib/TestExpectations 2020-10-20 06:40:43 UTC (rev 268715)
+++ trunk/LayoutTests/platform/glib/TestExpectations 2020-10-20 08:00:55 UTC (rev 268716)
@@ -1019,6 +1019,8 @@
imported/mozilla/svg/dynamic-textPath-02.svg [ Pass ]
imported/mozilla/svg/image/image-filter-01.svg [ Pass ]
+inspector/page/setScreenSizeOverride.html [ Pass ]
+
#////////////////////////////////////////////////////////////////////////////////////////
# End of PASSING tests.
#////////////////////////////////////////////////////////////////////////////////////////
Added: trunk/LayoutTests/platform/glib/inspector/page/setScreenSizeOverride-expected.txt (0 => 268716)
--- trunk/LayoutTests/platform/glib/inspector/page/setScreenSizeOverride-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/glib/inspector/page/setScreenSizeOverride-expected.txt 2020-10-20 08:00:55 UTC (rev 268716)
@@ -0,0 +1,12 @@
+
+== Running test suite: Page.setScreenSizeOverride
+-- Running test case: ScreenSizeOverrideOverride
+PASS: Body should be white.
+Overriding screen size to 1000x500
+PASS: Default screen width should be 1000.
+PASS: Default screen height should be 500.
+PASS: Body should be red.
+Removing screen size override
+PASS: Screen width override should be removed.
+PASS: Screen height override should be removed.
+
Modified: trunk/Source/_javascript_Core/ChangeLog (268715 => 268716)
--- trunk/Source/_javascript_Core/ChangeLog 2020-10-20 06:40:43 UTC (rev 268715)
+++ trunk/Source/_javascript_Core/ChangeLog 2020-10-20 08:00:55 UTC (rev 268716)
@@ -1,3 +1,12 @@
+2020-10-20 Philippe Normand <pnorm...@igalia.com> and Pavel Feldman <pavel.feld...@gmail.com>
+
+ Web Inspector: Add setScreenSizeOverride API to the Page agent
+ https://bugs.webkit.org/show_bug.cgi?id=213242
+
+ Reviewed by Devin Rousso.
+
+ * inspector/protocol/Page.json: Add a new setScreenSizeOverride API in the Page agent.
+
2020-10-19 Ross Kirsling <ross.kirsl...@sony.com>
%TypedArray%#sort helper functions should be globalPrivate
Modified: trunk/Source/_javascript_Core/inspector/protocol/Page.json (268715 => 268716)
--- trunk/Source/_javascript_Core/inspector/protocol/Page.json 2020-10-20 06:40:43 UTC (rev 268715)
+++ trunk/Source/_javascript_Core/inspector/protocol/Page.json 2020-10-20 08:00:55 UTC (rev 268716)
@@ -304,6 +304,16 @@
"returns": [
{ "name": "data", "type": "string", "description": "Base64-encoded web archive." }
]
+ },
+ {
+ "name": "setScreenSizeOverride",
+ "description": "Overrides screen size exposed to DOM and used in media queries for testing with provided values.",
+ "condition": "!(defined(WTF_PLATFORM_COCOA) && WTF_PLATFORM_COCOA)",
+ "targetTypes": ["page"],
+ "parameters": [
+ { "name": "width", "type": "integer", "description": "Screen width", "optional": true },
+ { "name": "height", "type": "integer", "description": "Screen height", "optional": true }
+ ]
}
],
"events": [
Modified: trunk/Source/WebCore/ChangeLog (268715 => 268716)
--- trunk/Source/WebCore/ChangeLog 2020-10-20 06:40:43 UTC (rev 268715)
+++ trunk/Source/WebCore/ChangeLog 2020-10-20 08:00:55 UTC (rev 268716)
@@ -1,3 +1,32 @@
+2020-10-20 Philippe Normand <pnorm...@igalia.com> and Pavel Feldman <pavel.feld...@gmail.com>
+
+ Web Inspector: Add setScreenSizeOverride API to the Page agent
+ https://bugs.webkit.org/show_bug.cgi?id=213242
+
+ Reviewed by Devin Rousso.
+
+ Allow the WebInspector Page agent to override the Screen size for media queries.
+
+ Test: inspector/page/setScreenSizeOverride.html
+
+ * css/MediaQueryEvaluator.cpp: Use the Frame::screenSize() method to query the screen dimensions.
+ (WebCore::deviceAspectRatioEvaluate):
+ (WebCore::deviceHeightEvaluate):
+ (WebCore::deviceWidthEvaluate):
+ * inspector/agents/InspectorPageAgent.cpp:
+ (WebCore::InspectorPageAgent::setScreenSizeOverride): Implementation of the new API hooking
+ into the WebCore::Frame::setOverrideScreenSize() method.
+ * inspector/agents/InspectorPageAgent.h:
+ * page/Frame.cpp:
+ (WebCore::Frame::screenSize const): New entry point to query the screen size, this takes into account the
+ optional overriden screen size.
+ (WebCore::Frame::setOverrideScreenSize): API used by the Page agent to fake a new screen size.
+ * page/Frame.h:
+ * page/Page.cpp:
+ * page/Screen.cpp: Use the Frame::screenSize() method to query the screen dimensions.
+ (WebCore::Screen::height const):
+ (WebCore::Screen::width const):
+
2020-10-02 Antoine Quint <grao...@webkit.org>
TranslateTransformOperation shouldn't take in a FloatSize to convert z as a double
Modified: trunk/Source/WebCore/css/MediaQueryEvaluator.cpp (268715 => 268716)
--- trunk/Source/WebCore/css/MediaQueryEvaluator.cpp 2020-10-20 06:40:43 UTC (rev 268715)
+++ trunk/Source/WebCore/css/MediaQueryEvaluator.cpp 2020-10-20 08:00:55 UTC (rev 268716)
@@ -390,7 +390,7 @@
if (!value)
return true;
- auto size = screenRect(frame.mainFrame().view()).size();
+ auto size = frame.mainFrame().screenSize();
bool result = compareAspectRatioValue(value, size.width(), size.height(), op);
LOG_WITH_STREAM(MediaQueries, stream << " deviceAspectRatioEvaluate: " << op << " " << aspectRatioValueAsString(value) << " actual screen size " << size << ": " << result);
return result;
@@ -508,7 +508,7 @@
if (!value)
return true;
int length;
- auto height = screenRect(frame.mainFrame().view()).height();
+ auto height = frame.mainFrame().screenSize().height();
if (!computeLength(value, !frame.document()->inQuirksMode(), conversionData, length))
return false;
@@ -524,7 +524,7 @@
if (!value)
return true;
int length;
- auto width = screenRect(frame.mainFrame().view()).width();
+ auto width = frame.mainFrame().screenSize().width();
if (!computeLength(value, !frame.document()->inQuirksMode(), conversionData, length))
return false;
Modified: trunk/Source/WebCore/inspector/agents/InspectorPageAgent.cpp (268715 => 268716)
--- trunk/Source/WebCore/inspector/agents/InspectorPageAgent.cpp 2020-10-20 06:40:43 UTC (rev 268715)
+++ trunk/Source/WebCore/inspector/agents/InspectorPageAgent.cpp 2020-10-20 08:00:55 UTC (rev 268716)
@@ -1106,4 +1106,21 @@
}
#endif
+#if !PLATFORM(COCOA)
+Protocol::ErrorStringOr<void> InspectorPageAgent::setScreenSizeOverride(Optional<int>&& width, Optional<int>&& height)
+{
+ if (width.hasValue() != height.hasValue())
+ return makeUnexpected("Screen width and height override should be both specified or omitted"_s);
+
+ if (width && *width <= 0)
+ return makeUnexpected("Screen width override should be a positive integer"_s);
+
+ if (height && *height <= 0)
+ return makeUnexpected("Screen height override should be a positive integer"_s);
+
+ m_inspectedPage.mainFrame().setOverrideScreenSize(FloatSize(width.valueOr(0), height.valueOr(0)));
+ return { };
+}
+#endif
+
} // namespace WebCore
Modified: trunk/Source/WebCore/inspector/agents/InspectorPageAgent.h (268715 => 268716)
--- trunk/Source/WebCore/inspector/agents/InspectorPageAgent.h 2020-10-20 06:40:43 UTC (rev 268715)
+++ trunk/Source/WebCore/inspector/agents/InspectorPageAgent.h 2020-10-20 08:00:55 UTC (rev 268716)
@@ -119,6 +119,9 @@
#if ENABLE(WEB_ARCHIVE) && USE(CF)
Inspector::Protocol::ErrorStringOr<String> archive();
#endif
+#if !PLATFORM(COCOA)
+ Inspector::Protocol::ErrorStringOr<void> setScreenSizeOverride(Optional<int>&& width, Optional<int>&& height);
+#endif
// InspectorInstrumentation
void domContentEventFired();
Modified: trunk/Source/WebCore/page/Frame.cpp (268715 => 268716)
--- trunk/Source/WebCore/page/Frame.cpp 2020-10-20 06:40:43 UTC (rev 268715)
+++ trunk/Source/WebCore/page/Frame.cpp 2020-10-20 08:00:55 UTC (rev 268716)
@@ -1067,6 +1067,23 @@
return m_localStoragePrewarmingCount < maxlocalStoragePrewarmingCount;
}
+FloatSize Frame::screenSize() const
+{
+ if (!m_overrideScreenSize.isEmpty())
+ return m_overrideScreenSize;
+ return screenRect(view()).size();
+}
+
+void Frame::setOverrideScreenSize(FloatSize&& screenSize)
+{
+ if (m_overrideScreenSize == screenSize)
+ return;
+
+ m_overrideScreenSize = WTFMove(screenSize);
+ if (auto* document = this->document())
+ document->updateViewportArguments();
+}
+
void Frame::selfOnlyRef()
{
ASSERT(isMainFrame());
Modified: trunk/Source/WebCore/page/Frame.h (268715 => 268716)
--- trunk/Source/WebCore/page/Frame.h 2020-10-20 06:40:43 UTC (rev 268715)
+++ trunk/Source/WebCore/page/Frame.h 2020-10-20 08:00:55 UTC (rev 268716)
@@ -309,6 +309,9 @@
void invalidateContentEventRegionsIfNeeded();
+ WEBCORE_EXPORT FloatSize screenSize() const;
+ void setOverrideScreenSize(FloatSize&&);
+
// ========
void selfOnlyRef();
@@ -372,6 +375,8 @@
bool m_hasHadUserInteraction { false };
unsigned m_localStoragePrewarmingCount { 0 };
+ FloatSize m_overrideScreenSize;
+
UniqueRef<EventHandler> m_eventHandler;
};
Modified: trunk/Source/WebCore/page/Page.cpp (268715 => 268716)
--- trunk/Source/WebCore/page/Page.cpp 2020-10-20 06:40:43 UTC (rev 268715)
+++ trunk/Source/WebCore/page/Page.cpp 2020-10-20 08:00:55 UTC (rev 268716)
@@ -89,6 +89,7 @@
#include "PerformanceLoggingClient.h"
#include "PerformanceMonitor.h"
#include "PlatformMediaSessionManager.h"
+#include "PlatformScreen.h"
#include "PlatformStrategies.h"
#include "PlugInClient.h"
#include "PluginData.h"
Modified: trunk/Source/WebCore/page/Screen.cpp (268715 => 268716)
--- trunk/Source/WebCore/page/Screen.cpp 2020-10-20 06:40:43 UTC (rev 268715)
+++ trunk/Source/WebCore/page/Screen.cpp 2020-10-20 08:00:55 UTC (rev 268716)
@@ -34,6 +34,7 @@
#include "FloatRect.h"
#include "Frame.h"
#include "FrameView.h"
+#include "Page.h"
#include "PlatformScreen.h"
#include "Quirks.h"
#include "ResourceLoadObserver.h"
@@ -56,7 +57,7 @@
return 0;
if (RuntimeEnabledFeatures::sharedFeatures().webAPIStatisticsEnabled())
ResourceLoadObserver::shared().logScreenAPIAccessed(*frame->document(), ResourceLoadStatistics::ScreenAPI::Height);
- long height = static_cast<long>(screenRect(frame->view()).height());
+ long height = static_cast<long>(frame->screenSize().height());
return static_cast<unsigned>(height);
}
@@ -67,7 +68,7 @@
return 0;
if (RuntimeEnabledFeatures::sharedFeatures().webAPIStatisticsEnabled())
ResourceLoadObserver::shared().logScreenAPIAccessed(*frame->document(), ResourceLoadStatistics::ScreenAPI::Width);
- long width = static_cast<long>(screenRect(frame->view()).width());
+ long width = static_cast<long>(frame->screenSize().width());
return static_cast<unsigned>(width);
}
Modified: trunk/Source/WebInspectorUI/ChangeLog (268715 => 268716)
--- trunk/Source/WebInspectorUI/ChangeLog 2020-10-20 06:40:43 UTC (rev 268715)
+++ trunk/Source/WebInspectorUI/ChangeLog 2020-10-20 08:00:55 UTC (rev 268716)
@@ -1,3 +1,14 @@
+2020-10-20 Philippe Normand <pnorm...@igalia.com>
+
+ Web Inspector: Add setScreenSizeOverride API to the Page agent
+ https://bugs.webkit.org/show_bug.cgi?id=213242
+
+ Reviewed by Devin Rousso.
+
+ * Localizations/en.lproj/localizedStrings.js:
+ * UserInterface/Base/Main.js:
+ (WI.loaded): Add a new drop-down menu allowing to override the device screen size.
+
2020-10-19 Patrick Angle <pan...@apple.com>
Web Inspector: Support three-column pane arrangement in Elements Tab
Modified: trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js (268715 => 268716)
--- trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js 2020-10-20 06:40:43 UTC (rev 268715)
+++ trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js 2020-10-20 08:00:55 UTC (rev 268716)
@@ -90,6 +90,9 @@
localizedStrings["0 Console errors"] = "0 Console errors";
localizedStrings["0 Console warnings"] = "0 Console warnings";
localizedStrings["1 match"] = "1 match";
+localizedStrings["1080p"] = "1080p";
+localizedStrings["720p"] = "720p";
+localizedStrings["Screen size:"] = "Screen size:";
localizedStrings["2D"] = "2D";
localizedStrings["Accessibility"] = "Accessibility";
localizedStrings["Action"] = "Action";
Modified: trunk/Source/WebInspectorUI/UserInterface/Base/Main.js (268715 => 268716)
--- trunk/Source/WebInspectorUI/UserInterface/Base/Main.js 2020-10-20 06:40:43 UTC (rev 268715)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/Main.js 2020-10-20 08:00:55 UTC (rev 268716)
@@ -167,6 +167,7 @@
WI.visible = false;
WI._windowKeydownListeners = [];
WI._overridenDeviceUserAgent = null;
+ WI._overridenDeviceScreenSize = null;
WI._overridenDeviceSettings = new Map;
// Targets.
@@ -2206,6 +2207,123 @@
}
});
+ if (InspectorBackend.hasCommand("Page.setScreenSizeOverride")) {
+ function applyOverriddenScreenSize(value, force) {
+ if (value === WI._overridenDeviceScreenSize)
+ return;
+
+ if (!force && (!value || value === "default")) {
+ target.PageAgent.setScreenSizeOverride((error) => {
+ if (error) {
+ WI.reportInternalError(error);
+ return;
+ }
+
+ WI._overridenDeviceScreenSize = null;
+ updateActivatedState();
+ target.PageAgent.reload();
+ });
+ } else {
+ let tokens = value.split("x");
+ let width = parseInt(tokens[0]);
+ let height = parseInt(tokens[1]);
+ target.PageAgent.setScreenSizeOverride(width, height, (error) => {
+ if (error) {
+ WI.reportInternalError(error);
+ return;
+ }
+
+ WI._overridenDeviceScreenSize = value;
+ updateActivatedState();
+ target.PageAgent.reload();
+ });
+ }
+ }
+
+
+ let screenSizeRow = table.appendChild(document.createElement("tr"));
+
+ let screenSizeTitle = screenSizeRow.appendChild(document.createElement("td"));
+ screenSizeTitle.textContent = WI.UIString("Screen size:");
+
+ let screenSizeValue = screenSizeRow.appendChild(document.createElement("td"));
+ screenSizeValue.classList.add("screen-size");
+
+ let screenSizeValueSelect = screenSizeValue.appendChild(document.createElement("select"));
+
+ let screenSizeValueInput = null;
+
+ const screenSizes = [
+ [
+ {name: WI.UIString("Default"), value: "default"},
+ ],
+ [
+ {name: WI.UIString("1080p"), value: "1920x1080"},
+ {name: WI.UIString("720p"), value: "1280x720"},
+ ],
+ [
+ {name: WI.UIString("Other\u2026"), value: "other"},
+ ],
+ ];
+
+ let selectedScreenSizeOptionElement = null;
+
+ for (let group of screenSizes) {
+ for (let {name, value} of group) {
+ let optionElement = screenSizeValueSelect.appendChild(document.createElement("option"));
+ optionElement.value = value;
+ optionElement.textContent = name;
+
+ if (value === WI._overridenDeviceScreenSize)
+ selectedScreenSizeOptionElement = optionElement;
+ }
+
+ if (group !== screenSizes.lastValue)
+ screenSizeValueSelect.appendChild(document.createElement("hr"));
+ }
+
+ function showScreenSizeInput() {
+ if (screenSizeValueInput)
+ return;
+
+ screenSizeValueInput = screenSizeValue.appendChild(document.createElement("input"));
+ screenSizeValueInput.spellcheck = false;
+ screenSizeValueInput.value = screenSizeValueInput.placeholder = WI._overridenDeviceScreenSize || (window.screen.width + "x" + window.screen.height);
+ screenSizeValueInput.addEventListener("click", (clickEvent) => {
+ clickEvent.preventDefault();
+ });
+ screenSizeValueInput.addEventListener("change", (inputEvent) => {
+ applyOverriddenScreenSize(screenSizeValueInput.value, true);
+ });
+
+ WI._deviceSettingsPopover.update();
+ }
+
+ if (selectedScreenSizeOptionElement)
+ screenSizeValueSelect.value = selectedScreenSizeOptionElement.value;
+ else if (WI._overridenDeviceScreenSize) {
+ screenSizeValueSelect.value = "other";
+ showScreenSizeInput();
+ }
+
+ screenSizeValueSelect.addEventListener("change", () => {
+ let value = screenSizeValueSelect.value;
+ if (value === "other") {
+ showScreenSizeInput();
+ screenSizeValueInput.select();
+ } else {
+ if (screenSizeValueInput) {
+ screenSizeValueInput.remove();
+ screenSizeValueInput = null;
+
+ WI._deviceSettingsPopover.update();
+ }
+
+ applyOverriddenScreenSize(value);
+ }
+ });
+ }
+
const settings = [
{
name: WI.UIString("Disable:"),