Bug 1032878 - Fix for various failing mochitest-plain/-chrome tests. r=jmaher, r=akachkach, r=surkov, r=cpearce

This commit is contained in:
Martijn Wargers 2014-08-10 20:03:50 -07:00
parent 9b4724133c
commit 37c3c7166b
12 changed files with 42 additions and 31 deletions

View File

@ -193,9 +193,9 @@
var tree4acc = getAccessible("tree4");
tree4element.parentNode.removeChild(tree4element);
waitForEvent(EVENT_REORDER, tree4acc, function() {
testGroupAttrs("tree4_ti2", 1, 1, 1); });
SimpleTest.finish();
testGroupAttrs("tree4_ti2", 1, 1, 1);
SimpleTest.finish();
});
}
SimpleTest.waitForExplicitFinish();

View File

@ -389,7 +389,7 @@ function eventQueue(aEventType)
var res = this.onFinish();
if (res != DO_NOT_FINISH_TEST)
SimpleTest.finish();
SimpleTest.executeSoon(SimpleTest.finish);
return;
}

View File

@ -89,6 +89,7 @@ function handleMessageEvents(event) {
break;
case 2:
is(event.data, "onupdate", "Child was successfully updated.");
clearInterval(intervalID);
finishTest();
break;
default:

View File

@ -35,6 +35,10 @@ function checkDefaultSrcOnly() {
ok(getElementColorById(testframe, 'unsafe-inline-script') === green, "Inline script should be allowed");
ok(getElementColorById(testframe, 'unsafe-eval-script') === green, "Eval should be allowed");
ok(getElementColorById(testframe, 'unsafe-inline-style') === green, "Inline style should be allowed");
document.getElementById('testframe2').src = 'file_CSP_bug888172.sjs?csp=' +
escape("default-src 'self' 'unsafe-inline' 'unsafe-eval'; script-src 'self'");
document.getElementById('testframe2').addEventListener('load', checkDefaultSrcWithScriptSrc, false);
}
function checkDefaultSrcWithScriptSrc() {
@ -43,6 +47,10 @@ function checkDefaultSrcWithScriptSrc() {
ok(getElementColorById(testframe, 'unsafe-inline-script') === black, "Inline script should be blocked");
ok(getElementColorById(testframe, 'unsafe-eval-script') === black, "Eval should be blocked");
ok(getElementColorById(testframe, 'unsafe-inline-style') === green, "Inline style should be allowed");
document.getElementById('testframe3').src = 'file_CSP_bug888172.sjs?csp=' +
escape("default-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self'");
document.getElementById('testframe3').addEventListener('load', checkDefaultSrcWithStyleSrc, false);
}
function checkDefaultSrcWithStyleSrc() {
@ -59,14 +67,6 @@ function checkDefaultSrcWithStyleSrc() {
document.getElementById('testframe1').src = 'file_CSP_bug888172.sjs?csp=' +
escape("default-src 'self' 'unsafe-inline' 'unsafe-eval'");
document.getElementById('testframe1').addEventListener('load', checkDefaultSrcOnly, false);
document.getElementById('testframe2').src = 'file_CSP_bug888172.sjs?csp=' +
escape("default-src 'self' 'unsafe-inline' 'unsafe-eval'; script-src 'self'");
document.getElementById('testframe2').addEventListener('load', checkDefaultSrcWithScriptSrc, false);
document.getElementById('testframe3').src = 'file_CSP_bug888172.sjs?csp=' +
escape("default-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self'");
document.getElementById('testframe3').addEventListener('load', checkDefaultSrcWithStyleSrc, false);
</script>
</pre>
</body>

View File

@ -28,6 +28,12 @@ function gotPlayEvent(event) {
" tokens["+v._state+"]=" + tokens[v._state] +
" tokens["+v._state+"].indexOf(event.type)=" + tokens[v._state].indexOf(event.type));
v._state = event.type;
if (event.type == 'canplaythrough') {
//canplaythrough event can fire multiple times on Windows
v.removeEventListener('canplaythrough', gotPlayEvent, false);
v.pause();
goToNext(v);
}
}
function goToNext(v) {
@ -46,8 +52,6 @@ function initTest(test, token) {
v.addEventListener(e, gotPlayEvent, false);
});
setTimeout(function() goToNext(v), 500);
v.src = test.name;
v.autoplay = true;
document.body.appendChild(v); // Causes load.

View File

@ -85,12 +85,6 @@ var tests = [
next();
}
req.continue();
try {
req.continue();
ok(false, "calling continue twice should fail");
} catch (e) {
ok(true, "calling continue twice should fail");
}
},
function() {
// FireDone

View File

@ -82,6 +82,11 @@ function eventHandler(e) {
}
if (nbEvents == 0) {
//removeEventListener, otherwise a key event is fired
//for some reason, with keyCode 95
removeEventListener('keydown', eventHandler);
removeEventListener('keypress', eventHandler);
removeEventListener('keyup', eventHandler);
SimpleTest.finish();
return;
}

View File

@ -28,6 +28,8 @@ function runTest() {
var numMsgReceived = 0;
function outerIframeLoaded() {
// If you're changing the amount of is() calls in injectedScript,
// also change the number in waitForMessages accordingly
var injectedScript =
"data:,function is(a, b, desc) { \
if (a == b) { \
@ -63,7 +65,8 @@ function outerIframeLoaded() {
mm.loadFrameScript(injectedScript, /* allowDelayedLoad = */ false);
waitForMessages(6);
// 8 is the number of is() calls in injectedScript
waitForMessages(8);
}
function waitForMessages(num) {

View File

@ -18,6 +18,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=960946
// The input context.
var gContext = null;
var gCounter = 0;
var gBackSpaceCounter = 0;
var result = ["keydown", "keypress", "keydown","keypress",
"keydown", "keypress", "keyup"
];
@ -26,11 +27,12 @@ inputmethod_setup(function() {
runTest();
});
var input;
// The frame script running in file_test_backspace_event.html.
function appFrameScript() {
let input = content.document.getElementById('test-input');
input.onkeydown = input.onkeypress = input.onkeyup = function(event) {
dump('key event was fired in file_test_backspace_event.html.\n');
dump('key event was fired in file_test_backspace_event.html: ' + event.type +'\n');
sendAsyncMessage('test:KeyBoard:keyEvent', {'type':event.type});
};
}
@ -67,9 +69,6 @@ function runTest() {
ok(true, 'Keyboard input was received.');
is(SpecialPowers.wrap(event).json.type, result[gCounter], "expected event");
gCounter++;
if (gCounter == 7) {
inputmethod_cleanup();
}
});
});
}
@ -93,6 +92,10 @@ function test_sendBackspace(repeat) {
// Send backspace
gContext.sendKey(KeyEvent.DOM_VK_BACK_SPACE, 0, 0, repeat).then(function() {
ok(true, 'sendKey success');
gBackSpaceCounter++;
if (gBackSpaceCounter == 3) {
inputmethod_cleanup();
}
}, function(e) {
ok(false, 'sendKey failed:' + e.name);
inputmethod_cleanup();

View File

@ -46,8 +46,6 @@
let mm1 = flo1.frameLoader.messageManager;
let mm2 = flo2.frameLoader.messageManager;
mm1.addMessageListener("pong", () => { gotPong(true); });
mm2.addMessageListener("pong", () => { gotPong(false); });
// Swap docshells. Everything should be identical to before, since there was nothing to
// distinguish these docshells.

View File

@ -4,10 +4,7 @@ this.Test = {
start: function(ok, is, finish) {
let worker = new ChromeWorker("jsm_url_worker.js");
worker.onmessage = function(event) {
if (event.data.type == 'finish') {
finish();
} else if (event.data.type == 'status') {
if (event.data.type == 'status') {
ok(event.data.status, event.data.msg);
} else if (event.data.type == 'url') {
var xhr = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]
@ -16,8 +13,13 @@ this.Test = {
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
ok(true, "Blob readable!");
finish();
}
}
xhr.onerror = function() {
ok(true, "Blob unreadable, should not happen!");
finish();
}
xhr.send();
}
};

View File

@ -45,6 +45,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=607529
// Protect against calling SimpleTest.finish() more than once.
if (!done) {
w.close();
window.onmessage = null;
SimpleTest.finish();
done = true;
}