Bug 1111433 - Add mochitest to verify SelectionStateChanged with blur state. r=ehsan

This commit is contained in:
pchang 2015-01-07 23:34:00 -05:00
parent 4f4888498d
commit a36507bcdf
6 changed files with 107 additions and 6 deletions

View File

@ -181,12 +181,15 @@ function testSelectAll(e) {
// Skip mozbrowser test if we're at child process.
if (!isChildProcess()) {
iframeOuter.addEventListener("mozbrowserselectionstatechanged", function selectchangeforselectall(e) {
iframeOuter.removeEventListener("mozbrowserselectionstatechanged", selectchangeforselectall, true);
ok(true, "got mozbrowserselectionstatechanged event." + 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.height != 0, "event.detail.height is not zero" + stateMeaning);
SimpleTest.executeSoon(function() { testCopy1(e); });
if (e.detail.states.indexOf('selectall') == 0) {
iframeOuter.removeEventListener("mozbrowserselectionstatechanged", selectchangeforselectall, true);
ok(true, "got mozbrowserselectionstatechanged event." + 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.height != 0, "event.detail.height is not zero" + stateMeaning);
ok(e.detail.states, "event.detail.state " + e.detail.states);
SimpleTest.executeSoon(function() { testCopy1(e); });
}
}, true);
}

View File

@ -0,0 +1,57 @@
/* Any copyright is dedicated to the public domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
// Bug 1111433: Send out the SelectionStateChanged event with Blur state
"use strict";
SimpleTest.waitForExplicitFinish();
browserElementTestHelpers.setEnabledPref(true);
browserElementTestHelpers.setSelectionChangeEnabledPref(true);
browserElementTestHelpers.addPermission();
var mm;
var iframe;
var changefocus = function () {
var elt = content.document.getElementById("text");
if (elt) {
elt.focus();
elt.select();
elt.blur();
}
}
function runTest() {
iframe = document.createElement('iframe');
iframe.setAttribute('mozbrowser', 'true');
document.body.appendChild(iframe);
mm = SpecialPowers.getBrowserFrameMessageManager(iframe);
iframe.src = "data:text/html,<html><body>" +
"<textarea id='text'> Bug 1111433 </textarea>"+
"</body></html>";
var loadtime = 0;
iframe.addEventListener("mozbrowserloadend", function onloadend(e) {
loadtime++;
if (loadtime === 2) {
iframe.removeEventListener("mozbrowserloadend", onloadend);
SimpleTest.executeSoon(function() { testBlur(e); });
}
});
}
function testBlur(e) {
iframe.addEventListener("mozbrowserselectionstatechanged", function selectionstatechanged(e) {
iframe.removeEventListener("mozbrowserselectionstatechanged", selectionstatechanged, true);
ok(e.detail.states.indexOf('blur') == 0, "received state " + e.detail.states);
SimpleTest.finish();
}, true);
iframe.focus();
mm.loadFrameScript('data:,(' + changefocus.toString() + ')();', false);
}
addEventListener('testready', runTest);

View File

@ -70,6 +70,8 @@ skip-if = (toolkit == 'gonk' && !debug)
[test_browserElement_oop_ScrollEvent.html]
[test_browserElement_oop_SecurityChange.html]
skip-if = toolkit == 'android' || (toolkit == 'gonk' && !debug) #TIMED_OUT, bug 766586
[test_browserElement_oop_SelectionStateBlur.html]
skip-if = (toolkit == 'gonk') # Disabled on b2g due to bug 1097419
[test_browserElement_oop_SendEvent.html]
[test_browserElement_oop_SetInputMethodActive.html]
skip-if = (os == "android")

View File

@ -53,6 +53,7 @@ support-files =
browserElement_ScrollEvent.js
browserElement_SecurityChange.js
browserElement_SendEvent.js
browserElement_SelectionStateBlur.js
browserElement_SetInputMethodActive.js
browserElement_SetVisible.js
browserElement_SetVisibleFrames.js
@ -184,6 +185,8 @@ skip-if = (toolkit == 'gonk' && !debug)
[test_browserElement_inproc_ScrollEvent.html]
[test_browserElement_inproc_SecurityChange.html]
skip-if = toolkit == 'android' || (toolkit == 'gonk' && !debug) # android(TIMED_OUT, bug 766586) androidx86(TIMED_OUT, bug 766586)
[test_browserElement_inproc_SelectionStateBlur.html]
skip-if = (toolkit == 'gonk') # Disabled on b2g due to bug 1097419
[test_browserElement_inproc_SendEvent.html]
# The setInputMethodActive() tests will timed out on Android
[test_browserElement_inproc_SetInputMethodActive.html]

View File

@ -0,0 +1,18 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1111433
-->
<head>
<title>Test for Bug 1111433</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="browserElementTestHelpers.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1111433">Mozilla Bug 1111433</a>
<script type="application/javascript;version=1.7" src="browserElement_SelectionStateBlur.js">
</script>
</body>
</html>

View File

@ -0,0 +1,18 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1111433
-->
<head>
<title>Test for Bug 1111433</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="browserElementTestHelpers.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1111433">Mozilla Bug 1111433</a>
<script type="application/javascript;version=1.7" src="browserElement_SelectionStateBlur.js">
</script>
</body>
</html>