Skip to content

Commit

Permalink
[ iOS ] 2x imported/w3c/web-platform-tests/screen-orientation are nea…
Browse files Browse the repository at this point in the history
…r-constant text failures.

https://bugs.webkit.org/show_bug.cgi?id=255931
rdar://108508861

Reviewed by Chris Dumez.

The cleanup function was accidentally calling "document.screen".
Fixing that revealed a bunch of smaller bugs in the tests.

* LayoutTests/TestExpectations:
* LayoutTests/imported/w3c/web-platform-tests/page-visibility/resources/window_state_context.js:
(window_state_context.async restore):
(window_state_context):
* LayoutTests/imported/w3c/web-platform-tests/resources/testdriver-vendor.js:
(async if):
(window.test_driver_internal.set_window_rect):
* LayoutTests/imported/w3c/web-platform-tests/screen-orientation/active-lock-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/screen-orientation/active-lock.html:
* LayoutTests/imported/w3c/web-platform-tests/screen-orientation/event-before-promise-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/screen-orientation/hidden_document-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/screen-orientation/hidden_document.html:
* LayoutTests/imported/w3c/web-platform-tests/screen-orientation/lock-basic-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/screen-orientation/nested-documents-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/screen-orientation/nested-documents.html:
* LayoutTests/imported/w3c/web-platform-tests/screen-orientation/onchange-event-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/screen-orientation/onchange-event-subframe-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/screen-orientation/onchange-event-subframe.html:
* LayoutTests/imported/w3c/web-platform-tests/screen-orientation/orientation-reading-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/screen-orientation/resources/orientation-utils.js:
* LayoutTests/imported/w3c/web-platform-tests/screen-orientation/unlock-expected.txt:
* LayoutTests/platform/ios/TestExpectations:

Canonical link: https://commits.webkit.org/263509@main
  • Loading branch information
marcoscaceres committed Apr 28, 2023
1 parent 19ef7f2 commit 5eb2125
Show file tree
Hide file tree
Showing 18 changed files with 52 additions and 57 deletions.
3 changes: 3 additions & 0 deletions LayoutTests/TestExpectations
Expand Up @@ -6262,3 +6262,6 @@ webkit.org/b/255101 imported/w3c/web-platform-tests/css/css-backgrounds/box-shad
webkit.org/b/255101 imported/w3c/web-platform-tests/css/css-backgrounds/box-shadow/slice-inline-fragmentation-001.html [ ImageOnlyFailure ]
webkit.org/b/255101 imported/w3c/web-platform-tests/css/css-backgrounds/box-shadow/slice-inline-fragmentation-002.html [ ImageOnlyFailure ]
webkit.org/b/255101 imported/w3c/web-platform-tests/css/css-backgrounds/box-shadow/slice-inline-fragmentation-003.html [ ImageOnlyFailure ]

# Flaky test that sometimes passes and sometimes fails.
imported/w3c/web-platform-tests/screen-orientation/nested-documents.html [ Pass Failure ]
Expand Up @@ -2,18 +2,19 @@ function window_state_context(t) {
let rect = null;
let state = "restored";
t.add_cleanup(async () => {
if (state === "minimized")
await restore();
if (state === "minimized") await restore();
});
async function restore() {
state = "restored";
if (state !== "minimized") return;
state = "restoring";
await test_driver.set_window_rect(rect);
state = "restored";
}

async function minimize() {
state = "minimized";
rect = await test_driver.minimize_window();
}

return {minimize, restore};
return { minimize, restore };
}
Expand Up @@ -467,7 +467,7 @@ window.test_driver_internal.minimize_window = async function (context=null)
*/
window.test_driver_internal.set_window_rect = async function (rect, context=null)
{
if (typeof rect !== "object" || typeof rect.width !== "number" || typeof rect.height !== "number")
if (!rect || typeof rect !== "object" || typeof rect.width !== "number" || typeof rect.height !== "number")
throw new Error("Invalid rect");

context = context ?? window;
Expand Down
@@ -1,8 +1,6 @@
fragment

Harness Error (FAIL), message = Test named 'Performing a fragment navigation must not abort the screen orientation change' specified 1 'cleanup' function, and 1 failed.

FAIL Performing a fragment navigation must not abort the screen orientation change promise_test: Unhandled rejection with value: object "NotSupportedError: Screen orientation locking is not supported"
NOTRUN Performing a fragment navigation within an iframe must not abort the lock promise
NOTRUN Unloading an iframe by navigating it must abort the lock promise
FAIL Performing a fragment navigation within an iframe must not abort the lock promise promise_test: Unhandled rejection with value: object "SecurityError: Locking the screen orientation is only allowed when in fullscreen"
FAIL Unloading an iframe by navigating it must abort the lock promise promise_rejects_dom: function "function () { throw e }" threw object "SecurityError: Locking the screen orientation is only allowed when in fullscreen" that is not a DOMException AbortError: property "code" is equal to 18, expected 20

Expand Up @@ -31,7 +31,7 @@
<p id="#fragment"></p>
<a href="#fragment">fragment</a>
`;
await test_driver.bless("request full screen");
await test_driver.bless("request full screen", null, iframe.contentWindow);
await document.documentElement.requestFullscreen();
const orientation = getOppositeOrientation();
const p = iframe.contentWindow.screen.orientation.lock(orientation);
Expand All @@ -43,7 +43,7 @@
promise_test(async (t) => {
t.add_cleanup(makeCleanup());
const iframe = await attachIframe();
await test_driver.bless("request full screen");
await test_driver.bless("request full screen", null, iframe.contentWindow);
await document.documentElement.requestFullscreen();
const orientation = getOppositeOrientation();
const p = iframe.contentWindow.screen.orientation.lock(orientation);
Expand Down
@@ -1,5 +1,3 @@

Harness Error (FAIL), message = Test named 'The 'change' event must fire before the [[orientationPendingPromise]] is resolved.' specified 1 'cleanup' function, and 1 failed.

FAIL The 'change' event must fire before the [[orientationPendingPromise]] is resolved. promise_test: Unhandled rejection with value: object "NotSupportedError: Screen orientation locking is not supported"

@@ -1,8 +1,6 @@

Harness Error (FAIL), message = Test named 'hidden documents must not unlock the screen orientation' specified 3 'cleanup' functions, and 2 failed.

PASS hidden documents must reject went trying to call lock or unlock
PASS hidden documents must reject went trying to call unlock
FAIL hidden documents must not unlock the screen orientation promise_test: Unhandled rejection with value: object "SecurityError: Locking the screen orientation is only allowed when in fullscreen"
NOTRUN Once maximized, a minimized window can lock or unlock the screen orientation again
FAIL hidden documents must not unlock the screen orientation promise_test: Unhandled rejection with value: object "NotSupportedError: Screen orientation locking is not supported"
FAIL Once maximized, a minimized window can lock or unlock the screen orientation again promise_test: Unhandled rejection with value: object "NotSupportedError: Screen orientation locking is not supported"

Expand Up @@ -19,7 +19,7 @@
await minimize();

assert_equals(document.visibilityState, "hidden", "Document must be hidden");
await promise_rejects_dom(t, "SecurityError", screen.orientation.lock("landscape") );
await promise_rejects_dom(t, "SecurityError", screen.orientation.lock(getOppositeOrientation()));
}, "hidden documents must reject went trying to call lock or unlock");

promise_test(async (t) => {
Expand All @@ -34,8 +34,10 @@

promise_test(async (t) => {
const { minimize, restore } = window_state_context(t);
t.add_cleanup(restore);
t.add_cleanup(makeCleanup());

await test_driver.bless("request full screen");
await document.documentElement.requestFullscreen();
await screen.orientation.lock(getOppositeOrientation());

await minimize();
Expand All @@ -46,8 +48,9 @@

promise_test(async (t) => {
const { minimize, restore } = window_state_context(t);
t.add_cleanup(restore);
t.add_cleanup(makeCleanup());
await test_driver.bless("request full screen");
await document.documentElement.requestFullscreen();
await screen.orientation.lock(getOppositeOrientation());

await minimize();
Expand All @@ -59,6 +62,9 @@
await restore();

assert_equals(document.visibilityState, "visible");

await test_driver.bless("request full screen");
await document.documentElement.requestFullscreen();
await screen.orientation.lock(getOppositeOrientation());
screen.orientation.unlock();
}, "Once maximized, a minimized window can lock or unlock the screen orientation again");
Expand Down
@@ -1,7 +1,5 @@

Harness Error (FAIL), message = Test named 'Test that screen.orientation.lock returns a promise which will be fulfilled with a void value.' specified 1 'cleanup' function, and 1 failed.

FAIL Test that screen.orientation.lock returns a promise which will be fulfilled with a void value. promise_test: Unhandled rejection with value: object "NotSupportedError: Screen orientation locking is not supported"
NOTRUN Test that screen.orientation.lock returns a pending promise.
NOTRUN Test that screen.orientation.lock() is actually async
PASS Test that screen.orientation.lock returns a pending promise.
FAIL Test that screen.orientation.lock() is actually async promise_test: Unhandled rejection with value: object "NotSupportedError: Screen orientation locking is not supported"

@@ -1,7 +1,10 @@
CONSOLE MESSAGE: Unhandled Promise Rejection: NotSupportedError: Screen orientation locking is not supported
CONSOLE MESSAGE: Unhandled Promise Rejection: SecurityError: Locking the screen orientation is only allowed when in fullscreen
CONSOLE MESSAGE: Unhandled Promise Rejection: NotSupportedError: Screen orientation locking is not supported


Harness Error (FAIL), message = Test named 'Requesting orientation lock from one document cancels the lock request from another document' specified 1 'cleanup' function, and 1 failed.
Harness Error (FAIL), message = Unhandled rejection: Screen orientation locking is not supported

FAIL Requesting orientation lock from one document cancels the lock request from another document promise_rejects_dom: function "function () { throw e }" threw object "SecurityError: Locking the screen orientation is only allowed when in fullscreen" that is not a DOMException AbortError: property "code" is equal to 18, expected 20
NOTRUN The orientation lock from one document affects lock requests from other documents
FAIL The orientation lock from one document affects lock requests from other documents promise_rejects_dom: Expected request to lock orientation from iframe 0 to abort function "function () { throw e }" threw object "SecurityError: Locking the screen orientation is only allowed when in fullscreen" that is not a DOMException AbortError: property "code" is equal to 18, expected 20

Expand Up @@ -37,7 +37,7 @@

promise_test(async (t) => {
t.add_cleanup(makeCleanup());
// Create 3 nested iframes
// Create 2 nested iframes
const src = "/screen-orientation/resources/empty.html";
const outerIframe = await attachIframe({ src: `${src}#1` });
const innerIframe = await attachIframe({
Expand All @@ -49,11 +49,9 @@

// Go full screen
await test_driver.bless(
"request full screen",
null,
innerIframe.contentWindow
"request full screen"
);
await innerIframe.contentDocument.documentElement.requestFullscreen();
await document.documentElement.requestFullscreen();
const opposite = getOppositeOrientation();

// Each iframe tries to lock the orientation
Expand All @@ -68,20 +66,16 @@
const topPromise = window.screen.orientation.lock(opposite);

// Check that all promises are rejected with AbortError
const abortedPromises = [];
for (let i = 0; i < requestToLock.length; i++) {
const { promise, context } = requestToLock[i];
const p = promise_rejects_dom(
await promise_rejects_dom(
t,
"AbortError",
context.DOMException,
promise,
`Expected request to lock orientation from iframe ${i} to abort`
);
abortedPromises.push(p);
}
await Promise.all(abortedPromises);

// Finally, top-level promise resolves
await topPromise;
}, "The orientation lock from one document affects lock requests from other documents");
Expand Down
@@ -1,6 +1,4 @@

Harness Error (FAIL), message = Test named 'Test that orientationchange event is not fired when the orientation does not change.' specified 1 'cleanup' function, and 1 failed.

FAIL Test that orientationchange event is not fired when the orientation does not change. promise_test: Unhandled rejection with value: object "NotSupportedError: Screen orientation locking is not supported"
NOTRUN Test that orientationchange event is fired when the orientation changes.
FAIL Test that orientationchange event is fired when the orientation changes. promise_test: Unhandled rejection with value: object "NotSupportedError: Screen orientation locking is not supported"

@@ -1,7 +1,7 @@


Harness Error (FAIL), message = Test named 'Test subframes receive orientation change events' specified 1 'cleanup' function, and 1 failed.
Harness Error (FAIL), message = Timeout while running cleanup for test named "Check directly that events are fired in right order (from top to bottom)".

FAIL Test subframes receive orientation change events promise_test: Unhandled rejection with value: object "NotSupportedError: Screen orientation locking is not supported"
NOTRUN Check directly that events are fired in right order (from top to bottom)
FAIL Check directly that events are fired in right order (from top to bottom) promise_test: Unhandled rejection with value: object "NotSupportedError: Screen orientation locking is not supported"

Expand Up @@ -44,7 +44,14 @@
promise_test(async (t) => {
t.add_cleanup(makeCleanup());
const iframe = await attachIframe();
const opposite = getOppositeOrientation();
let opposite = getOppositeOrientation();

// Fail fast in case the API is not supported
await test_driver.bless("request fullscreen", null, iframe.contentWindow);
await iframe.contentDocument.documentElement.requestFullscreen();
await iframe.contentWindow.screen.orientation.lock(opposite);
iframe.contentWindow.screen.orientation.unlock();
opposite = getOppositeOrientation();

const topEventPromise = new EventWatcher(
t,
Expand Down
@@ -1,10 +1,8 @@

Harness Error (FAIL), message = Test named 'Test the orientations and associated angles when the natural orientation is 'portrait'' specified 1 'cleanup' function, and 1 failed.

PASS screen.orientation attributes are present
PASS Test the orientations and associated angles when the natural orientation is 'portrait'
NOTRUN Test the orientations and associated angles when the natural orientation is 'landscape'
PASS Test the orientations and associated angles when the natural orientation is 'landscape'
PASS Test that ScreenOrientation properties are not writable
PASS Test that ScreenOrientation is always the same object
NOTRUN Test that ScreenOrientation's attribute values change after 'change' event fires
FAIL Test that ScreenOrientation's attribute values change after 'change' event fires promise_test: Unhandled rejection with value: object "NotSupportedError: Screen orientation locking is not supported"

Expand Up @@ -35,11 +35,9 @@ export function getOppositeOrientation() {

export function makeCleanup() {
return async () => {
document.screen.orientation.unlock();
screen.orientation.unlock();
if (document.fullscreenElement) {
try {
await document.exitFullscreen();
} catch {}
await document.fullscreenElement.ownerDocument.exitFullscreen();
}
};
}
@@ -1,9 +1,8 @@

Harness Error (FAIL), message = Test named 'unlock() doesn't throw when there is no lock with fullscreen' specified 1 'cleanup' function, and 1 failed.

PASS unlock() doesn't throw when there is no lock
PASS unlock() returns a void value
PASS unlock() doesn't throw when there is no lock with fullscreen
NOTRUN unlock() aborts a pending lock request
NOTRUN unlock() aborts a pending lock request across documents
FAIL unlock() aborts a pending lock request promise_rejects_dom: function "function () { throw e }" threw object "NotSupportedError: Screen orientation locking is not supported" that is not a DOMException AbortError: property "code" is equal to 9, expected 20
FAIL unlock() aborts a pending lock request across documents promise_rejects_dom: function "function () { throw e }" threw object "SecurityError: Locking the screen orientation is only allowed when in fullscreen" that is not a DOMException AbortError: property "code" is equal to 18, expected 20

4 changes: 0 additions & 4 deletions LayoutTests/platform/ios/TestExpectations
Expand Up @@ -2990,10 +2990,6 @@ webkit.org/b/173041 http/tests/websocket/tests/hybi/handshake-ok-with-legacy-sec

webkit.org/b/230968 http/tests/websocket/tests/hybi/bad-handshake-crash.html [ Skip ]

# webkit.org/b/255931 2x imported/w3c/web-platform-tests/screen-orientation are near constant failures
imported/w3c/web-platform-tests/screen-orientation/nested-documents.html [ Failure ]
imported/w3c/web-platform-tests/screen-orientation/unlock.html [ Failure ]

# WK2 spelling dot test infrastructure isn't hooked up on iOS
webkit.org/b/190764 editing/spelling/spelling-dots-repaint.html [ Skip ]
webkit.org/b/190764 editing/spelling/spelling-dots-position.html [ Skip ]
Expand Down

0 comments on commit 5eb2125

Please sign in to comment.