mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 502273 contentEditable is disabled if an attribute is removed from the node r+sr=peterv
This commit is contained in:
parent
e84048c06c
commit
245ec4860e
@ -1139,14 +1139,14 @@ nsGenericHTMLElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
|
||||
PRBool contentEditable = PR_FALSE;
|
||||
PRInt32 contentEditableChange;
|
||||
|
||||
if (aNameSpaceID == kNameSpaceID_None) {
|
||||
contentEditable = PR_TRUE;
|
||||
contentEditableChange = GetContentEditableValue() == eTrue ? -1 : 0;
|
||||
}
|
||||
|
||||
// Check for event handlers
|
||||
if (aNameSpaceID == kNameSpaceID_None) {
|
||||
if (nsContentUtils::IsEventAttributeName(aAttribute, EventNameType_HTML)) {
|
||||
if (aAttribute == nsGkAtoms::contenteditable) {
|
||||
contentEditable = PR_TRUE;
|
||||
contentEditableChange = GetContentEditableValue() == eTrue ? -1 : 0;
|
||||
}
|
||||
else if (nsContentUtils::IsEventAttributeName(aAttribute,
|
||||
EventNameType_HTML)) {
|
||||
nsIEventListenerManager* manager = GetListenerManager(PR_FALSE);
|
||||
if (manager) {
|
||||
manager->RemoveScriptEventListener(aAttribute);
|
||||
|
@ -30,41 +30,113 @@ function runTest()
|
||||
var focused;
|
||||
anchorInEditor.onfocus = function() { focused = true; };
|
||||
|
||||
function isReallyEditable()
|
||||
{
|
||||
editor.focus();
|
||||
var range = document.createRange();
|
||||
range.selectNodeContents(editor);
|
||||
var prevStr = range.toString();
|
||||
|
||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||||
var docShell =
|
||||
window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
|
||||
.getInterface(Components.interfaces.nsIWebNavigation)
|
||||
.QueryInterface(Components.interfaces.nsIDocShell);
|
||||
var controller =
|
||||
docShell.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
|
||||
.getInterface(Components.interfaces.nsISelectionDisplay)
|
||||
.QueryInterface(Components.interfaces.nsISelectionController);
|
||||
var sel = controller.getSelection(controller.SELECTION_NORMAL);
|
||||
sel.collapse(anchorInEditor, 0);
|
||||
synthesizeKey('a', {});
|
||||
range.selectNodeContents(editor);
|
||||
return prevStr != range.toString();
|
||||
}
|
||||
|
||||
focused = false;
|
||||
anchor.focus();
|
||||
editor.setAttribute("contenteditable", "true");
|
||||
anchorInEditor.focus();
|
||||
is(focused, false, "focus moved to element in contenteditable=true");
|
||||
is(isReallyEditable(), true, "cannot edit by a key event");
|
||||
|
||||
// for bug 502273
|
||||
focused = false;
|
||||
anchor.focus();
|
||||
editor.setAttribute("dummy", "dummy");
|
||||
editor.removeAttribute("dummy");
|
||||
anchorInEditor.focus();
|
||||
is(focused, false, "focus moved to element in contenteditable=true (after dummy attribute was removed)");
|
||||
is(isReallyEditable(), true, "cannot edit by a key event");
|
||||
|
||||
focused = false;
|
||||
anchor.focus();
|
||||
editor.setAttribute("contenteditable", "false");
|
||||
anchorInEditor.focus();
|
||||
is(focused, true, "focus didn't move to element in contenteditable=false");
|
||||
is(isReallyEditable(), false, "can edit by a key event");
|
||||
|
||||
// for bug 502273
|
||||
focused = false;
|
||||
anchor.focus();
|
||||
editor.setAttribute("dummy", "dummy");
|
||||
editor.removeAttribute("dummy");
|
||||
anchorInEditor.focus();
|
||||
is(focused, true, "focus moved to element in contenteditable=true (after dummy attribute was removed)");
|
||||
is(isReallyEditable(), false, "cannot edit by a key event");
|
||||
|
||||
focused = false;
|
||||
anchor.focus();
|
||||
editor.setAttribute("contenteditable", "true");
|
||||
anchorInEditor.focus();
|
||||
is(focused, false, "focus moved to element in contenteditable=true");
|
||||
is(isReallyEditable(), true, "cannot edit by a key event");
|
||||
|
||||
// for bug 502273
|
||||
focused = false;
|
||||
anchor.focus();
|
||||
editor.setAttribute("dummy", "dummy");
|
||||
editor.removeAttribute("dummy");
|
||||
anchorInEditor.focus();
|
||||
is(focused, false, "focus moved to element in contenteditable=true (after dummy attribute was removed)");
|
||||
is(isReallyEditable(), true, "cannot edit by a key event");
|
||||
|
||||
focused = false;
|
||||
anchor.focus();
|
||||
editor.removeAttribute("contenteditable");
|
||||
anchorInEditor.focus();
|
||||
is(focused, true, "focus didn't move to element in contenteditable removed element");
|
||||
is(isReallyEditable(), false, "can edit by a key event");
|
||||
|
||||
focused = false;
|
||||
anchor.focus();
|
||||
editor.contentEditable = true;
|
||||
anchorInEditor.focus();
|
||||
is(focused, false, "focus moved to element in contenteditable=true by property");
|
||||
is(isReallyEditable(), true, "cannot edit by a key event");
|
||||
|
||||
focused = false;
|
||||
anchor.focus();
|
||||
editor.contentEditable = false;
|
||||
anchorInEditor.focus();
|
||||
is(focused, true, "focus didn't move to element in contenteditable=false by property");
|
||||
is(isReallyEditable(), false, "can edit by a key event");
|
||||
|
||||
focused = false;
|
||||
anchor.focus();
|
||||
editor.setAttribute("contenteditable", "true");
|
||||
anchorInEditor.focus();
|
||||
is(focused, false, "focus moved to element in contenteditable=true");
|
||||
is(isReallyEditable(), true, "cannot edit by a key event");
|
||||
|
||||
// for bug 502273
|
||||
focused = false;
|
||||
anchor.focus();
|
||||
editor.setAttribute("dummy", "dummy");
|
||||
editor.removeAttribute("dummy");
|
||||
anchorInEditor.focus();
|
||||
is(focused, false, "focus moved to element in contenteditable=true (after dummy attribute was removed)");
|
||||
is(isReallyEditable(), true, "cannot edit by a key event");
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
Loading…
Reference in New Issue
Block a user