mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-09 16:57:36 +00:00
Bug 614563 - isolate text attribute change event test from attributes/test_text, r=marcoz, a=test
This commit is contained in:
parent
5348754520
commit
3a76bfc6f1
@ -17,61 +17,8 @@
|
||||
src="../events.js"></script>
|
||||
|
||||
<script type="application/javascript">
|
||||
|
||||
const nsIDOMNSEditableElement =
|
||||
Components.interfaces.nsIDOMNSEditableElement;
|
||||
|
||||
var gComputedStyle = null;
|
||||
|
||||
var gTextAttrChangedEventHandler = {
|
||||
handleEvent: function gTextAttrChangedEventHandler_handleEvent(aEvent)
|
||||
{
|
||||
this.eventNumber++;
|
||||
},
|
||||
|
||||
eventNumber: 0
|
||||
};
|
||||
|
||||
function testSpellTextAttrs()
|
||||
{
|
||||
registerA11yEventListener(nsIAccessibleEvent.EVENT_TEXT_ATTRIBUTE_CHANGED,
|
||||
gTextAttrChangedEventHandler);
|
||||
|
||||
ID = "area8";
|
||||
|
||||
var node = document.getElementById(ID);
|
||||
node.setAttribute("value", "valid text inalid tixt");
|
||||
node.focus();
|
||||
|
||||
var editor = node.QueryInterface(nsIDOMNSEditableElement).editor;
|
||||
var spellchecker = editor.getInlineSpellChecker(true);
|
||||
spellchecker.enableRealTimeSpell = true;
|
||||
|
||||
window.setTimeout(function()
|
||||
{
|
||||
var defAttrs = buildDefaultTextAttrs(node, kInputFontSize);
|
||||
testDefaultTextAttrs(ID, defAttrs);
|
||||
|
||||
var attrs = { };
|
||||
var misspelledAttrs = {
|
||||
"invalid": "spelling"
|
||||
};
|
||||
|
||||
testTextAttrs(ID, 0, attrs, defAttrs, 0, 11);
|
||||
testTextAttrs(ID, 11, misspelledAttrs, defAttrs, 11, 17);
|
||||
testTextAttrs(ID, 17, attrs, defAttrs, 17, 18);
|
||||
testTextAttrs(ID, 18, misspelledAttrs, defAttrs, 18, 22);
|
||||
|
||||
is(gTextAttrChangedEventHandler.eventNumber, 2,
|
||||
"Wrong count of 'text attribute changed' events for " + ID);
|
||||
|
||||
unregisterA11yEventListener(nsIAccessibleEvent.EVENT_TEXT_ATTRIBUTE_CHANGED,
|
||||
gTextAttrChangedEventHandler);
|
||||
|
||||
SimpleTest.finish();
|
||||
}, 0);
|
||||
}
|
||||
|
||||
function doTest()
|
||||
{
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@ -458,9 +405,7 @@
|
||||
// p
|
||||
testTextAttrs(ID, 23, { }, { }, 23, 24);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// test spelling text attributes
|
||||
testSpellTextAttrs(); // Will call SimpleTest.finish();
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
@ -521,8 +466,6 @@
|
||||
</span>
|
||||
</p>
|
||||
|
||||
<input id="area8"/>
|
||||
|
||||
<p id="area9" style="font-size: smaller">Small
|
||||
<span style="font-size: 120%">bigger</span> smaller
|
||||
<span style="background-color: blue;">background blue</span> normal
|
||||
|
@ -16,6 +16,7 @@ const EVENT_SELECTION_ADD = nsIAccessibleEvent.EVENT_SELECTION_ADD;
|
||||
const EVENT_SELECTION_WITHIN = nsIAccessibleEvent.EVENT_SELECTION_WITHIN;
|
||||
const EVENT_SHOW = nsIAccessibleEvent.EVENT_SHOW;
|
||||
const EVENT_STATE_CHANGE = nsIAccessibleEvent.EVENT_STATE_CHANGE;
|
||||
const EVENT_TEXT_ATTRIBUTE_CHANGED = nsIAccessibleEvent.EVENT_TEXT_ATTRIBUTE_CHANGED;
|
||||
const EVENT_TEXT_CARET_MOVED = nsIAccessibleEvent.EVENT_TEXT_CARET_MOVED;
|
||||
const EVENT_TEXT_INSERTED = nsIAccessibleEvent.EVENT_TEXT_INSERTED;
|
||||
const EVENT_TEXT_REMOVED = nsIAccessibleEvent.EVENT_TEXT_REMOVED;
|
||||
|
@ -70,6 +70,7 @@ _TEST_FILES =\
|
||||
test_selection.html \
|
||||
test_statechange.html \
|
||||
test_text.html \
|
||||
test_textattrchange.html \
|
||||
test_tree.xul \
|
||||
test_valuechange.html \
|
||||
$(NULL)
|
||||
|
102
accessible/tests/mochitest/events/test_textattrchange.html
Normal file
102
accessible/tests/mochitest/events/test_textattrchange.html
Normal file
@ -0,0 +1,102 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>Text attribute changed event for misspelled text</title>
|
||||
|
||||
<link rel="stylesheet" type="text/css"
|
||||
href="chrome://mochikit/content/tests/SimpleTest/test.css" />
|
||||
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/MochiKit/packed.js"></script>
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
|
||||
|
||||
<script type="application/javascript"
|
||||
src="../common.js"></script>
|
||||
<script type="application/javascript"
|
||||
src="../events.js"></script>
|
||||
<script type="application/javascript"
|
||||
src="../attributes.js"></script>
|
||||
|
||||
<script type="application/javascript">
|
||||
|
||||
const nsIDOMNSEditableElement =
|
||||
Components.interfaces.nsIDOMNSEditableElement;
|
||||
|
||||
function spelledTextInvoker(aID)
|
||||
{
|
||||
this.DOMNode = getNode(aID);
|
||||
|
||||
this.eventSeq = [
|
||||
new invokerChecker(EVENT_TEXT_ATTRIBUTE_CHANGED, this.DOMNode)
|
||||
];
|
||||
|
||||
this.invoke = function spelledTextInvoker_invoke()
|
||||
{
|
||||
this.DOMNode.setAttribute("value", "valid text inalid tixt");
|
||||
this.DOMNode.focus();
|
||||
|
||||
var editor = this.DOMNode.QueryInterface(nsIDOMNSEditableElement).editor;
|
||||
var spellchecker = editor.getInlineSpellChecker(true);
|
||||
spellchecker.enableRealTimeSpell = true;
|
||||
}
|
||||
|
||||
this.finalCheck = function spelledTextInvoker_finalCheck()
|
||||
{
|
||||
var defAttrs = buildDefaultTextAttrs(this.DOMNode, kInputFontSize);
|
||||
testDefaultTextAttrs(aID, defAttrs);
|
||||
|
||||
var attrs = { };
|
||||
var misspelledAttrs = {
|
||||
"invalid": "spelling"
|
||||
};
|
||||
|
||||
testTextAttrs(aID, 0, attrs, defAttrs, 0, 11);
|
||||
testTextAttrs(aID, 11, misspelledAttrs, defAttrs, 11, 17);
|
||||
testTextAttrs(aID, 17, attrs, defAttrs, 17, 18);
|
||||
testTextAttrs(aID, 18, misspelledAttrs, defAttrs, 18, 22);
|
||||
}
|
||||
|
||||
this.getID = function spelledTextInvoker_getID()
|
||||
{
|
||||
return "text attribute change for misspelled text";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Do tests.
|
||||
*/
|
||||
//gA11yEventDumpID = "eventdump"; // debug stuff
|
||||
|
||||
var gQueue = null;
|
||||
function doTests()
|
||||
{
|
||||
gQueue = new eventQueue();
|
||||
gQueue.push(new spelledTextInvoker("area8"));
|
||||
gQueue.invoke(); // Will call SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addA11yLoadEvent(doTests);
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<a target="_blank"
|
||||
href="https://bugzilla.mozilla.org/show_bug.cgi?id=345759"
|
||||
title="Implement text attributes">
|
||||
Mozilla Bug 345759
|
||||
</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none"></div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
|
||||
<input id="area8"/>
|
||||
|
||||
<div id="eventdump"></div>
|
||||
</body>
|
||||
</html>
|
Loading…
x
Reference in New Issue
Block a user