Backed out changeset 4c37121d2837 (bug 1788741) for causing focus and ResizeObserver wpt related failures. CLOSED TREE

This commit is contained in:
Cosmin Sabou 2023-02-11 06:52:27 +02:00
Родитель 7d2749470d
Коммит 476c8e75fb
3 изменённых файлов: 92 добавлений и 75 удалений

Просмотреть файл

@ -18,8 +18,6 @@
namespace mozilla::dom {
constexpr auto kFlushTypeToObserve = FlushType::Layout;
void ResizeObserverNotificationHelper::WillRefresh(TimeStamp aTime) {
MOZ_DIAGNOSTIC_ASSERT(mOwner, "Should've de-registered on-time!");
mOwner->Notify();
@ -52,8 +50,7 @@ void ResizeObserverNotificationHelper::Register() {
return;
}
refreshDriver->AddRefreshObserver(this, kFlushTypeToObserve,
"ResizeObserver");
refreshDriver->AddRefreshObserver(this, FlushType::Display, "ResizeObserver");
mRegistered = true;
}
@ -67,7 +64,7 @@ void ResizeObserverNotificationHelper::Unregister() {
refreshDriver,
"We should not leave a dangling reference to the observer around");
bool rv = refreshDriver->RemoveRefreshObserver(this, kFlushTypeToObserve);
bool rv = refreshDriver->RemoveRefreshObserver(this, FlushType::Display);
MOZ_DIAGNOSTIC_ASSERT(rv, "Should remove the observer successfully");
Unused << rv;

Просмотреть файл

@ -0,0 +1,20 @@
[focus-fixup-rule-one-no-dialogs.html]
expected:
if (os == "android") and fission: [OK, TIMEOUT]
[Disabling contenteditable]
expected: FAIL
[Hiding the active element]
expected: FAIL
[Changing the first legend element in disabled <fieldset>]
expected: FAIL
[Disabling <fieldset> affects its descendants]
expected: FAIL
[Removing the tabindex attribute from a div]
expected: FAIL
[Disabling the active element (making it inert)]
expected: FAIL

Просмотреть файл

@ -15,95 +15,95 @@
<fieldset id="fieldset2" disabled><legend><button id="button5">Button 5</button></legend></fieldset>
<div id="div" tabindex="0">Div</div>
<div id="editable" contenteditable=true>editor</div>
<button id="button6">Button 6</button>
</div>
<script>
"use strict";
function test_focus_fixup(selector, change, expectSync = false) {
promise_test(async function(t) {
// Make sure we're not running from a ResizeObserver / etc notification.
await new Promise(r => t.step_timeout(r, 0));
test(() => {
const button = document.querySelector("#button1");
button.focus();
const el = document.querySelector(selector);
el.focus();
assert_equals(document.activeElement, button, "Sanity check: the button must start focused");
assert_equals(document.activeElement, el, `Sanity check: ${selector} must start focused`);
change(el);
{
const fn = expectSync ? assert_not_equals : assert_equals;
fn(document.activeElement, el, `active element ${expectSync ? "is" : "isn't"} fixed-up sync`);
}
// We don't expect blur events in the sync case per spec yet, at least.
if (!expectSync) {
// Fixup should run after animation frame callbacks, right before the end of
// "update the rendering", so after resize observations but before
// intersection observations.
let ranRaf = false;
let resolveDone;
let done = new Promise(r => { resolveDone = r; });
requestAnimationFrame(t.step_func(() => {
ranRaf = true;
assert_equals(document.activeElement, el, "activeElement shouldn't have changed yet (rAF)");
}));
let ro = new ResizeObserver(t.step_func(() => {
assert_true(ranRaf, "requestAnimationFrame should run before ResizeObserver");
assert_equals(document.activeElement, el, "activeElement shouldn't have changed yet (ResizeObserver)");
resolveDone();
}));
// TODO: Test IntersectionObserver timing. It's a bit trickier because it
// uses its own task source and so on.
ro.observe(document.documentElement);
await done;
ro.disconnect();
}
assert_not_equals(document.activeElement, el, "focus is fixed up");
assert_equals(document.activeElement, document.body, "Body is focused");
}, selector);
}
test_focus_fixup("#button1", function(button) {
button.disabled = true;
});
test_focus_fixup("#button2", function(button) {
assert_not_equals(document.activeElement, button, "After disabling, the button must no longer be focused");
assert_equals(document.activeElement, document.body, "After disabling, the body must be focused");
}, "Disabling the active element (making it inert)");
test(() => {
const button = document.querySelector("#button2");
button.focus();
assert_equals(document.activeElement, button, "Sanity check: the button must start focused");
button.hidden = true;
});
test_focus_fixup("#button3", function(button) {
assert_not_equals(document.activeElement, button, "After hiding, the button must no longer be focused");
assert_equals(document.activeElement, document.body, "After hiding, the body must be focused");
}, "Hiding the active element");
test(() => {
const button = document.querySelector("#button3");
button.focus();
assert_equals(document.activeElement, button, "Sanity check: the button must start focused");
button.remove();
}, /* expectSync = */ true);
test_focus_fixup("#button4", function(button) {
document.querySelector("#fieldset1").disabled = true;
});
assert_not_equals(document.activeElement, button, "After removing, the button must no longer be focused");
assert_equals(document.activeElement, document.body, "After removing, the body must be focused");
test_focus_fixup("#button5", function(button) {
}, "Removing the active element from the DOM");
test(() => {
const fieldset = document.querySelector("#fieldset1");
const button = document.querySelector("#button4");
button.focus();
assert_equals(document.activeElement, button, "Sanity check: the button must start focused");
fieldset.disabled = true;
assert_not_equals(document.activeElement, button, "After disabling ancestor fieldset, the button must no longer be focused");
assert_equals(document.activeElement, document.body, "After disabling ancestor fieldset, the body must be focused");
}, "Disabling <fieldset> affects its descendants");
test(() => {
const fieldset = document.querySelector("#fieldset2");
const button = document.querySelector("#button5");
button.focus();
assert_equals(document.activeElement, button, "Sanity check: the button must start focused");
fieldset.insertBefore(document.createElement("legend"), fieldset.firstChild);
});
test_focus_fixup("#div", function(div) {
assert_not_equals(document.activeElement, button, "After changing a legend element, the button must no longer be focused");
assert_equals(document.activeElement, document.body, "After changing a legend element, the body must be focused");
}, "Changing the first legend element in disabled <fieldset>");
test(() => {
const div = document.querySelector("#div");
div.focus();
assert_equals(document.activeElement, div, "Sanity check: the div must start focused");
div.removeAttribute("tabindex");
});
test_focus_fixup("#editable", function(div) {
assert_not_equals(document.activeElement, div, "After removing tabindex, the div must no longer be focused");
assert_equals(document.activeElement, document.body, "After removing tabindex, the body must be focused");
}, "Removing the tabindex attribute from a div");
test(() => {
const div = document.querySelector("#editable");
div.focus();
assert_equals(document.activeElement, div, "Sanity check: the div must start focused");
div.contentEditable = false;
});
test_focus_fixup("#button6", function(button) {
button.style.visibility = "hidden";
});
assert_not_equals(document.activeElement, div, "After disabling contentEditable, the div must no longer be focused");
assert_equals(document.activeElement, document.body, "After disabling contentEditable, the body must be focused");
}, "Disabling contenteditable");
</script>