Bug 1155493 - Part 4: Add test for mozbrowsercaretstatechanged. r=kchen

This commit is contained in:
Morris Tseng 2015-05-19 21:00:00 -04:00
parent cb0b085920
commit bb669f48bb
2 changed files with 27 additions and 11 deletions

View File

@ -65,6 +65,10 @@ const browserElementTestHelpers = {
this._setPref('selectioncaret.enabled', value); this._setPref('selectioncaret.enabled', value);
}, },
setAccessibleCaretEnabledPref: function(value) {
this._setPref('layout.accessiblecaret.enabled', value);
},
getOOPByDefaultPref: function() { getOOPByDefaultPref: function() {
return this._getBoolPref("dom.ipc.browser_frames.oop_by_default"); return this._getBoolPref("dom.ipc.browser_frames.oop_by_default");
}, },

View File

@ -21,6 +21,7 @@ var defaultData;
var pasteData; var pasteData;
var focusScript; var focusScript;
var createEmbededFrame = false; var createEmbededFrame = false;
var testAccessibleCaret = false;
function copyToClipboard(str) { function copyToClipboard(str) {
gTextarea.value = str; gTextarea.value = str;
@ -160,16 +161,24 @@ function dispatchTest(e) {
break; break;
default: default:
if (createEmbededFrame || browserElementTestHelpers.getOOPByDefaultPref()) { if (createEmbededFrame || browserElementTestHelpers.getOOPByDefaultPref()) {
if (testAccessibleCaret) {
SimpleTest.finish(); SimpleTest.finish();
return;
} else {
testAccessibleCaret = true;
createEmbededFrame = false;
browserElementTestHelpers.setSelectionChangeEnabledPref(false);
browserElementTestHelpers.setAccessibleCaretEnabledPref(true);
}
} else { } else {
createEmbededFrame = true; createEmbededFrame = true;
}
// clean up and run test again. // clean up and run test again.
document.body.removeChild(iframeOuter); document.body.removeChild(iframeOuter);
document.body.removeChild(gTextarea); document.body.removeChild(gTextarea);
state = 0; state = 0;
runTest(); runTest();
}
break; break;
} }
} }
@ -183,14 +192,17 @@ function isChildProcess() {
function testSelectAll(e) { function testSelectAll(e) {
// Skip mozbrowser test if we're at child process. // Skip mozbrowser test if we're at child process.
if (!isChildProcess()) { if (!isChildProcess()) {
iframeOuter.addEventListener("mozbrowserselectionstatechanged", function selectchangeforselectall(e) { let eventName = testAccessibleCaret ? "mozbrowsercaretstatechanged" : "mozbrowserselectionstatechanged";
if (e.detail.states.indexOf('selectall') == 0) { iframeOuter.addEventListener(eventName, function selectchangeforselectall(e) {
iframeOuter.removeEventListener("mozbrowserselectionstatechanged", selectchangeforselectall, true); if (!e.detail.states || e.detail.states.indexOf('selectall') == 0) {
iframeOuter.removeEventListener(eventName, selectchangeforselectall, true);
ok(true, "got mozbrowserselectionstatechanged event." + stateMeaning); ok(true, "got mozbrowserselectionstatechanged event." + stateMeaning);
ok(e.detail, "event.detail is not null." + stateMeaning); ok(e.detail, "event.detail is not null." + stateMeaning);
ok(e.detail.width != 0, "event.detail.width is not zero" + stateMeaning); ok(e.detail.width != 0, "event.detail.width is not zero" + stateMeaning);
ok(e.detail.height != 0, "event.detail.height is not zero" + stateMeaning); ok(e.detail.height != 0, "event.detail.height is not zero" + stateMeaning);
if (!testAccessibleCaret) {
ok(e.detail.states, "event.detail.state " + e.detail.states); ok(e.detail.states, "event.detail.state " + e.detail.states);
}
SimpleTest.executeSoon(function() { testCopy1(e); }); SimpleTest.executeSoon(function() { testCopy1(e); });
} }
}, true); }, true);