зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 2 changesets (bug 1723010) for causing mochitest failures on test_bug226361.xhtml. CLOSED TREE
Backed out changeset 62facfd599d0 (bug 1723010) Backed out changeset 94c9836864cf (bug 1723010)
This commit is contained in:
Родитель
60811c73f8
Коммит
121a8c8434
|
@ -31,7 +31,6 @@
|
|||
#include "mozilla/Maybe.h"
|
||||
#include "mozilla/PseudoStyleType.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "mozilla/Result.h"
|
||||
#include "mozilla/RustCell.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "mozilla/dom/BorrowedAttrInfo.h"
|
||||
|
@ -1658,15 +1657,11 @@ class Element : public FragmentOrElement {
|
|||
* @param aKeyCausesActivation - if true then element should be activated
|
||||
* @param aIsTrustedEvent - if true then event that is cause of accesskey
|
||||
* execution is trusted.
|
||||
* @return an error if the element isn't able to handle the accesskey (caller
|
||||
* would look for the next element to handle it).
|
||||
* a boolean indicates whether the focus moves to the element after
|
||||
* the element handles the accesskey.
|
||||
* @return true if the focus was changed.
|
||||
*/
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
virtual Result<bool, nsresult> PerformAccesskey(bool aKeyCausesActivation,
|
||||
bool aIsTrustedEvent) {
|
||||
return Err(NS_ERROR_NOT_IMPLEMENTED);
|
||||
MOZ_CAN_RUN_SCRIPT virtual bool PerformAccesskey(bool aKeyCausesActivation,
|
||||
bool aIsTrustedEvent) {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
|
|
@ -1161,10 +1161,8 @@ bool EventStateManager::LookForAccessKeyAndExecute(
|
|||
}
|
||||
}
|
||||
|
||||
auto result =
|
||||
element->PerformAccesskey(shouldActivate, aIsTrustedEvent);
|
||||
if (result.isOk()) {
|
||||
if (result.unwrap() && aIsTrustedEvent) {
|
||||
if (element->PerformAccesskey(shouldActivate, aIsTrustedEvent)) {
|
||||
if (aIsTrustedEvent) {
|
||||
// If this is a child process, inform the parent that we want the
|
||||
// focus, but pass false since we don't want to change the window
|
||||
// order.
|
||||
|
|
|
@ -26,7 +26,6 @@ support-files =
|
|||
!/gfx/layers/apz/test/mochitest/apz_test_utils.js
|
||||
|
||||
[test_accel_virtual_modifier.html]
|
||||
[test_accesskey.html]
|
||||
[test_addEventListenerExtraArg.html]
|
||||
[test_all_synthetic_events.html]
|
||||
[test_bug1539497.html]
|
||||
|
|
|
@ -1,130 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Accesskey</title>
|
||||
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<p id="display"></p>
|
||||
<!-- Tests for lable -->
|
||||
<label id="label1" accesskey="a">Label 1</label><br>
|
||||
<label id="label2" accesskey="a" for="checkbox2">Label 2</label><input type="checkbox" id="checkbox2" disabled>Checkbox 2</input><br>
|
||||
<label id="label3" accesskey="a" for="checkbox3">Label 3</label><input type="checkbox" id="checkbox3">Checkbox 3</input><br>
|
||||
<!-- Tests for button -->
|
||||
<button id="button1" accesskey="b" style="display: none;">Button 1</button><br>
|
||||
<button id="button2" accesskey="b">Button 2</button><br>
|
||||
<button id="button3" accesskey="b" disabled>Button 3</button><br>
|
||||
<button id="button4" accesskey="b">Button 4</button><br>
|
||||
<!-- Tests for legend -->
|
||||
<fieldset>
|
||||
<legend accesskey="c">Legend 1</legend>
|
||||
<input type="radio" id="radio1" style="display: none;"><label for="radio1">Radio 1</label><br>
|
||||
<input type="radio" id="radio2" disabled><label for="radio2">Radio 2</label><br>
|
||||
<input type="radio" id="radio3"><label for="radio3">Radio 3</label><br>
|
||||
</fieldset>
|
||||
<!-- Tests for legend2 -->
|
||||
<fieldset>
|
||||
<legend accesskey="d">Legend 2</legend>
|
||||
<input type="radio" id="radio4" disabled><label for="radio4">Radio 4</label><br>
|
||||
</fieldset>
|
||||
<input type="text" id="text1" accesskey="d"><br>
|
||||
<!-- Tests for bug 1723010 -->
|
||||
<button id="button5" style="display:none" accesskey="1">Button 5</button>
|
||||
<button id="button6" style="display:none" accesskey="2">Button 6</button>
|
||||
<textarea id="textarea1" accesskey="2"></textarea>
|
||||
<script>
|
||||
|
||||
function performAccessKey(aKey) {
|
||||
synthesizeKey(aKey, (navigator.platform.includes("Mac")) ?
|
||||
{ altKey : true, ctrlKey : true } :
|
||||
{ altKey : true, shiftKey: true });
|
||||
}
|
||||
|
||||
add_task(function label() {
|
||||
let checkbox3 = document.getElementById("checkbox3");
|
||||
|
||||
performAccessKey("a");
|
||||
is(document.activeElement.id, checkbox3.id, `focus should move to ${checkbox3.id}`);
|
||||
ok(!checkbox3.checked, `${checkbox3.id} should be still unchecked`);
|
||||
});
|
||||
|
||||
add_task(function button() {
|
||||
let button2 = document.getElementById("button2");
|
||||
let button4 = document.getElementById("button4");
|
||||
|
||||
[button2, button4].forEach(function(element) {
|
||||
element.addEventListener("click", function() {
|
||||
ok(false, `${element.id} should not be clicked`);
|
||||
});
|
||||
});
|
||||
|
||||
performAccessKey("b");
|
||||
is(document.activeElement.id, button2.id, `focus should move to ${button2.id}`);
|
||||
|
||||
performAccessKey("b");
|
||||
is(document.activeElement.id, button4.id, `focus should move to ${button4.id}`);
|
||||
});
|
||||
|
||||
add_task(function legend() {
|
||||
let radio3 = document.getElementById("radio3");
|
||||
|
||||
performAccessKey("c");
|
||||
is(document.activeElement.id, radio3.id, `focus should move to ${radio3.id}`);
|
||||
ok(!radio3.checked, `${radio3.id} should be still unchecked`);
|
||||
});
|
||||
|
||||
add_task(function legend2() {
|
||||
let text1 = document.getElementById("text1");
|
||||
|
||||
performAccessKey("d");
|
||||
is(document.activeElement.id, text1.id, `focus should move to ${text1.id}`);
|
||||
});
|
||||
|
||||
/** Test for Bug 1723010 **/
|
||||
|
||||
add_task(async function removeElement() {
|
||||
let button5 = document.getElementById("button5");
|
||||
let textarea1 = document.getElementById("textarea1");
|
||||
let promise = new Promise((resolve) => {
|
||||
button5.addEventListener("click", function() {
|
||||
textarea1.remove();
|
||||
SimpleTest.executeSoon(() => {
|
||||
ok(true, "should not crash");
|
||||
resolve();
|
||||
});
|
||||
}, { once: true });
|
||||
});
|
||||
|
||||
performAccessKey("1");
|
||||
await promise;
|
||||
});
|
||||
|
||||
add_task(async function modifyAccessKey() {
|
||||
let button5 = document.getElementById("button5");
|
||||
let button6 = document.getElementById("button6");
|
||||
let textarea1 = document.querySelector("textarea1");
|
||||
let promise = new Promise((resolve) => {
|
||||
button5.addEventListener("click", function() {
|
||||
button5.setAttribute("accesskey", "2");
|
||||
button6.setAttribute("accesskey", "1");
|
||||
SimpleTest.executeSoon(() => {
|
||||
ok(true, "Button 5 should be clicked");
|
||||
resolve();
|
||||
});
|
||||
}, { once: true });
|
||||
|
||||
button6.addEventListener("click", function() {
|
||||
ok(false, "Button 6 should not be clicked");
|
||||
}, { once: true });
|
||||
});
|
||||
|
||||
performAccessKey("1");
|
||||
await promise;
|
||||
});
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -177,28 +177,26 @@ nsresult HTMLLabelElement::PostHandleEvent(EventChainPostVisitor& aVisitor) {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
Result<bool, nsresult> HTMLLabelElement::PerformAccesskey(
|
||||
bool aKeyCausesActivation, bool aIsTrustedEvent) {
|
||||
bool HTMLLabelElement::PerformAccesskey(bool aKeyCausesActivation,
|
||||
bool aIsTrustedEvent) {
|
||||
if (!aKeyCausesActivation) {
|
||||
RefPtr<Element> element = GetLabeledElement();
|
||||
if (element) {
|
||||
return element->PerformAccesskey(aKeyCausesActivation, aIsTrustedEvent);
|
||||
}
|
||||
return Err(NS_ERROR_ABORT);
|
||||
} else {
|
||||
nsPresContext* presContext = GetPresContext(eForUncomposedDoc);
|
||||
if (!presContext) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Click on it if the users prefs indicate to do so.
|
||||
AutoPopupStatePusher popupStatePusher(
|
||||
aIsTrustedEvent ? PopupBlocker::openAllowed : PopupBlocker::openAbused);
|
||||
DispatchSimulatedClick(this, aIsTrustedEvent, presContext);
|
||||
}
|
||||
|
||||
nsPresContext* presContext = GetPresContext(eForUncomposedDoc);
|
||||
if (!presContext) {
|
||||
return Err(NS_ERROR_UNEXPECTED);
|
||||
}
|
||||
|
||||
// Click on it if the users prefs indicate to do so.
|
||||
AutoPopupStatePusher popupStatePusher(
|
||||
aIsTrustedEvent ? PopupBlocker::openAllowed : PopupBlocker::openAbused);
|
||||
DispatchSimulatedClick(this, aIsTrustedEvent, presContext);
|
||||
|
||||
// XXXedgar, do we need to check whether the focus is really changed?
|
||||
return true;
|
||||
return aKeyCausesActivation;
|
||||
}
|
||||
|
||||
nsGenericHTMLElement* HTMLLabelElement::GetLabeledElement() const {
|
||||
|
|
|
@ -48,8 +48,7 @@ class HTMLLabelElement final : public nsGenericHTMLElement {
|
|||
// nsIContent
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
||||
virtual nsresult PostHandleEvent(EventChainPostVisitor& aVisitor) override;
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
virtual Result<bool, nsresult> PerformAccesskey(
|
||||
MOZ_CAN_RUN_SCRIPT virtual bool PerformAccesskey(
|
||||
bool aKeyCausesActivation, bool aIsTrustedEvent) override;
|
||||
virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
|
||||
|
||||
|
|
|
@ -93,18 +93,13 @@ void HTMLLegendElement::Focus(const FocusOptions& aOptions,
|
|||
getter_AddRefs(result));
|
||||
}
|
||||
|
||||
Result<bool, nsresult> HTMLLegendElement::PerformAccesskey(
|
||||
bool aKeyCausesActivation, bool aIsTrustedEvent) {
|
||||
bool HTMLLegendElement::PerformAccesskey(bool aKeyCausesActivation,
|
||||
bool aIsTrustedEvent) {
|
||||
FocusOptions options;
|
||||
ErrorResult rv;
|
||||
|
||||
Focus(options, CallerType::System, rv);
|
||||
if (rv.Failed()) {
|
||||
return Err(rv.StealNSResult());
|
||||
}
|
||||
|
||||
// XXXedgar, do we need to check whether the focus is really changed?
|
||||
return true;
|
||||
return NS_SUCCEEDED(rv.StealNSResult());
|
||||
}
|
||||
|
||||
HTMLLegendElement::LegendAlignValue HTMLLegendElement::LogicalAlign(
|
||||
|
|
|
@ -27,8 +27,8 @@ class HTMLLegendElement final : public nsGenericHTMLElement {
|
|||
const mozilla::dom::CallerType aCallerType,
|
||||
ErrorResult& aError) override;
|
||||
|
||||
virtual Result<bool, nsresult> PerformAccesskey(
|
||||
bool aKeyCausesActivation, bool aIsTrustedEvent) override;
|
||||
virtual bool PerformAccesskey(bool aKeyCausesActivation,
|
||||
bool aIsTrustedEvent) override;
|
||||
|
||||
// nsIContent
|
||||
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
|
||||
|
|
|
@ -2409,11 +2409,11 @@ bool nsGenericHTMLElement::IsHTMLFocusable(bool aWithMouse, bool* aIsFocusable,
|
|||
return disallowOverridingFocusability;
|
||||
}
|
||||
|
||||
Result<bool, nsresult> nsGenericHTMLElement::PerformAccesskey(
|
||||
bool aKeyCausesActivation, bool aIsTrustedEvent) {
|
||||
bool nsGenericHTMLElement::PerformAccesskey(bool aKeyCausesActivation,
|
||||
bool aIsTrustedEvent) {
|
||||
nsPresContext* presContext = GetPresContext(eForComposedDoc);
|
||||
if (!presContext) {
|
||||
return Err(NS_ERROR_UNEXPECTED);
|
||||
return false;
|
||||
}
|
||||
|
||||
// It's hard to say what HTML4 wants us to do in all cases.
|
||||
|
@ -2431,13 +2431,9 @@ Result<bool, nsresult> nsGenericHTMLElement::PerformAccesskey(
|
|||
AutoPopupStatePusher popupStatePusher(
|
||||
aIsTrustedEvent ? PopupBlocker::openAllowed : PopupBlocker::openAbused);
|
||||
DispatchSimulatedClick(this, aIsTrustedEvent, presContext);
|
||||
return focused;
|
||||
}
|
||||
|
||||
// If the accesskey won't cause the activation and the focus isn't changed,
|
||||
// either. Return error so EventStateManager would try to find next element
|
||||
// to handle the accesskey.
|
||||
return focused ? Result<bool, nsresult>{focused} : Err(NS_ERROR_ABORT);
|
||||
return focused;
|
||||
}
|
||||
|
||||
void nsGenericHTMLElement::HandleKeyboardActivation(
|
||||
|
|
|
@ -282,8 +282,7 @@ class nsGenericHTMLElement : public nsGenericHTMLElementBase {
|
|||
*/
|
||||
virtual bool IsHTMLFocusable(bool aWithMouse, bool* aIsFocusable,
|
||||
int32_t* aTabIndex);
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
virtual mozilla::Result<bool, nsresult> PerformAccesskey(
|
||||
MOZ_CAN_RUN_SCRIPT virtual bool PerformAccesskey(
|
||||
bool aKeyCausesActivation, bool aIsTrustedEvent) override;
|
||||
|
||||
/**
|
||||
|
|
|
@ -461,25 +461,25 @@ void nsXULElement::OpenMenu(bool aOpenFlag) {
|
|||
}
|
||||
}
|
||||
|
||||
Result<bool, nsresult> nsXULElement::PerformAccesskey(bool aKeyCausesActivation,
|
||||
bool aIsTrustedEvent) {
|
||||
bool nsXULElement::PerformAccesskey(bool aKeyCausesActivation,
|
||||
bool aIsTrustedEvent) {
|
||||
if (IsXULElement(nsGkAtoms::label)) {
|
||||
nsAutoString control;
|
||||
GetAttr(kNameSpaceID_None, nsGkAtoms::control, control);
|
||||
if (control.IsEmpty()) {
|
||||
return Err(NS_ERROR_UNEXPECTED);
|
||||
return false;
|
||||
}
|
||||
|
||||
// XXXsmaug Should we use ShadowRoot::GetElementById in case
|
||||
// element is in Shadow DOM?
|
||||
RefPtr<Document> document = GetUncomposedDoc();
|
||||
if (!document) {
|
||||
return Err(NS_ERROR_UNEXPECTED);
|
||||
return false;
|
||||
}
|
||||
|
||||
RefPtr<Element> element = document->GetElementById(control);
|
||||
if (!element) {
|
||||
return Err(NS_ERROR_UNEXPECTED);
|
||||
return false;
|
||||
}
|
||||
|
||||
// XXXedgar, This is mainly for HTMLElement which doesn't do visible
|
||||
|
@ -488,7 +488,7 @@ Result<bool, nsresult> nsXULElement::PerformAccesskey(bool aKeyCausesActivation,
|
|||
// label XULelement per spec.
|
||||
nsIFrame* frame = element->GetPrimaryFrame();
|
||||
if (!frame || !frame->IsVisibleConsideringAncestors()) {
|
||||
return Err(NS_ERROR_UNEXPECTED);
|
||||
return false;
|
||||
}
|
||||
|
||||
return element->PerformAccesskey(aKeyCausesActivation, aIsTrustedEvent);
|
||||
|
@ -496,7 +496,7 @@ Result<bool, nsresult> nsXULElement::PerformAccesskey(bool aKeyCausesActivation,
|
|||
|
||||
nsIFrame* frame = GetPrimaryFrame();
|
||||
if (!frame || !frame->IsVisibleConsideringAncestors()) {
|
||||
return Err(NS_ERROR_UNEXPECTED);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool focused = false;
|
||||
|
@ -529,13 +529,9 @@ Result<bool, nsresult> nsXULElement::PerformAccesskey(bool aKeyCausesActivation,
|
|||
if (aKeyCausesActivation && !IsXULElement(nsGkAtoms::menulist)) {
|
||||
ClickWithInputSource(MouseEvent_Binding::MOZ_SOURCE_KEYBOARD,
|
||||
aIsTrustedEvent);
|
||||
return focused;
|
||||
}
|
||||
|
||||
// If the accesskey won't cause the activation and the focus isn't changed,
|
||||
// either. Return error so EventStateManager would try to find next element
|
||||
// to handle the accesskey.
|
||||
return focused ? Result<bool, nsresult>{focused} : Err(NS_ERROR_ABORT);
|
||||
return focused;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
|
|
@ -376,8 +376,7 @@ class nsXULElement : public nsStyledElement {
|
|||
MOZ_CAN_RUN_SCRIPT bool HasMenu();
|
||||
MOZ_CAN_RUN_SCRIPT void OpenMenu(bool aOpenFlag);
|
||||
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
virtual mozilla::Result<bool, nsresult> PerformAccesskey(
|
||||
MOZ_CAN_RUN_SCRIPT virtual bool PerformAccesskey(
|
||||
bool aKeyCausesActivation, bool aIsTrustedEvent) override;
|
||||
void ClickWithInputSource(uint16_t aInputSource, bool aIsTrustedEvent);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче