Bug 869869 - Part 4, add IPC mochitest for PeerConnection, r=bent.

This commit is contained in:
Shih-Chiang Chien 2013-08-23 23:47:49 +08:00
Родитель 32ecc31c85
Коммит 38ca23da5e
8 изменённых файлов: 193 добавлений и 1 удалений

Просмотреть файл

@ -7,7 +7,7 @@
if CONFIG['MOZ_WEBRTC']:
DIRS += ['bridge']
TEST_DIRS += ['tests/mochitest']
TEST_DIRS += ['tests/mochitest', 'tests/ipc']
XPIDL_SOURCES += [
'nsIDOMMediaStream.idl',

Просмотреть файл

@ -0,0 +1,4 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.

Просмотреть файл

@ -0,0 +1,3 @@
[DEFAULT]
[test_ipc.html]

Просмотреть файл

@ -0,0 +1,7 @@
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
MOCHITEST_MANIFESTS += ['mochitest.ini']

Просмотреть файл

@ -0,0 +1,175 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test for OOP PeerConncection</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<script type="application/javascript;version=1.7">
"use strict";
SimpleTest.waitForExplicitFinish();
// This isn't a single test. It runs the entirety of the PeerConnection
// tests. Each of those has a normal timeout handler, so there's no point in
// having a timeout here. I'm setting this really high just to avoid getting
// killed.
SimpleTest.requestLongerTimeout(100);
// Disable crash observers as it breaks later tests.
function iframeScriptFirst() {
SpecialPowers.prototype.registerProcessCrashObservers = function() { };
SpecialPowers.prototype.unregisterProcessCrashObservers = function() { };
content.wrappedJSObject.RunSet.reloadAndRunAll({
preventDefault: function() { },
__exposedProps__: { preventDefault: 'r' }
});
}
function iframeScriptSecond() {
let TestRunner = content.wrappedJSObject.TestRunner;
let oldComplete = TestRunner.onComplete;
TestRunner.onComplete = function() {
TestRunner.onComplete = oldComplete;
sendAsyncMessage("test:PeerConnection:ipcTestComplete", {
result: JSON.stringify(TestRunner._failedTests)
});
if (oldComplete) {
oldComplete();
}
};
let oldLog = TestRunner.log;
TestRunner.log = function(msg) {
sendAsyncMessage("test:PeerConnection:ipcTestMessage", { msg: msg });
}
}
let regex = /^(TEST-PASS|TEST-UNEXPECTED-PASS|TEST-KNOWN-FAIL|TEST-UNEXPECTED-FAIL|TEST-DEBUG-INFO) \| ([^\|]+) \|(.*)/;
function onTestMessage(data) {
let message = SpecialPowers.wrap(data).json.msg;
let match = regex.exec(message);
if (match) {
let state = match[1];
let details = match[2] + " | " + match[3];
switch (state) {
case "TEST-PASS":
case "TEST-KNOWN-FAIL":
ok(true, details);
break;
case "TEST-UNEXPECTED-FAIL":
case "TEST-UNEXPECTED-PASS":
ok(false, details);
break;
case "TEST-DEBUG-INFO":
default:
info(details);
}
}
}
function onTestComplete() {
let comp = SpecialPowers.wrap(SpecialPowers.Components);
let mm = SpecialPowers.getBrowserFrameMessageManager(iframe);
let spObserver = comp.classes["@mozilla.org/special-powers-observer;1"]
.getService(comp.interfaces.nsIMessageListener);
mm.removeMessageListener("SPPrefService", spObserver);
mm.removeMessageListener("SPProcessCrashService", spObserver);
mm.removeMessageListener("SPPingService", spObserver);
mm.removeMessageListener("SpecialPowers.Quit", spObserver);
mm.removeMessageListener("SPPermissionManager", spObserver);
mm.removeMessageListener("test:PeerConnection:ipcTestMessage", onTestMessage);
mm.removeMessageListener("test:PeerConnection:ipcTestComplete", onTestComplete);
SimpleTest.executeSoon(function () { SimpleTest.finish(); });
}
function runTests() {
let iframe = document.createElement("iframe");
SpecialPowers.wrap(iframe).mozbrowser = true;
iframe.id = "iframe";
iframe.style.width = "100%";
iframe.style.height = "1000px";
function iframeLoadSecond() {
ok(true, "Got second iframe load event.");
iframe.removeEventListener("mozbrowserloadend", iframeLoadSecond);
let mm = SpecialPowers.getBrowserFrameMessageManager(iframe);
mm.loadFrameScript("data:,(" + iframeScriptSecond.toString() + ")();",
false);
}
function iframeLoadFirst() {
ok(true, "Got first iframe load event.");
iframe.removeEventListener("mozbrowserloadend", iframeLoadFirst);
iframe.addEventListener("mozbrowserloadend", iframeLoadSecond);
let mm = SpecialPowers.getBrowserFrameMessageManager(iframe);
let comp = SpecialPowers.wrap(SpecialPowers.Components);
let spObserver =
comp.classes["@mozilla.org/special-powers-observer;1"]
.getService(comp.interfaces.nsIMessageListener);
mm.addMessageListener("SPPrefService", spObserver);
mm.addMessageListener("SPProcessCrashService", spObserver);
mm.addMessageListener("SPPingService", spObserver);
mm.addMessageListener("SpecialPowers.Quit", spObserver);
mm.addMessageListener("SPPermissionManager", spObserver);
mm.addMessageListener("test:PeerConnection:ipcTestMessage", onTestMessage);
mm.addMessageListener("test:PeerConnection:ipcTestComplete", onTestComplete);
let specialPowersBase = "chrome://specialpowers/content/";
mm.loadFrameScript(specialPowersBase + "MozillaLogger.js", false);
mm.loadFrameScript(specialPowersBase + "specialpowersAPI.js", false);
mm.loadFrameScript(specialPowersBase + "specialpowers.js", false);
mm.loadFrameScript("data:,(" + iframeScriptFirst.toString() + ")();", false);
}
iframe.addEventListener("mozbrowserloadend", iframeLoadFirst);
// Strip this filename and one directory level and then add "/mochitest".
let href = window.location.href;
href = href.substring(0, href.lastIndexOf('/'));
href = href.substring(0, href.lastIndexOf('/'));
iframe.src = href + "/mochitest?consoleLevel=INFO";
document.body.appendChild(iframe);
}
addEventListener("load", function() {
SpecialPowers.addPermission("browser", true, document);
SpecialPowers.pushPrefEnv({
"set": [
["media.peerconnection.ipc.enabled", true],
// TODO: remove this as part of bug 820712
["network.disable.ipc.security", true],
["dom.ipc.browser_frames.oop_by_default", true],
["dom.mozBrowserFramesEnabled", true],
["browser.pagethumbnails.capturing_disabled", true]
]
}, runTests);
});
</script>
</body>
</html>

Просмотреть файл

@ -149,6 +149,7 @@
"dom/network/tests/test_network_basics.html": "",
"dom/permission/tests/test_permission_basics.html": "",
"dom/mobilemessage/tests/test_sms_basics.html": "Bug 909036",
"dom/media/tests/ipc/test_ipc.html":"bug 910661",
"dom/tests/mochitest/ajax/jquery/test_jQuery.html": "bug 775227",
"dom/tests/mochitest/ajax/offline/test_simpleManifest.html": "TIMED_OUT",
"dom/tests/mochitest/ajax/offline/test_updatingManifest.html": "TIMED_OUT",

Просмотреть файл

@ -320,6 +320,7 @@
"dom/media/tests/mochitest/test_peerConnection_setRemoteAnswerInStable.html":"",
"dom/media/tests/mochitest/test_peerConnection_setRemoteOfferInHaveLocalOffer.html":"",
"dom/media/tests/mochitest/test_peerConnection_throwInCallbacks.html":"",
"dom/media/tests/ipc/test_ipc.html":"nested ipc not working",
"dom/network/tests/test_networkstats_basics.html":"Will be fixed in bug 858005",
"dom/permission/tests/test_permission_basics.html":"Bug 907770",

Просмотреть файл

@ -325,6 +325,7 @@
"dom/media/tests/mochitest/test_peerConnection_setRemoteAnswerInStable.html":"",
"dom/media/tests/mochitest/test_peerConnection_setRemoteOfferInHaveLocalOffer.html":"",
"dom/media/tests/mochitest/test_peerConnection_throwInCallbacks.html":"",
"dom/media/tests/ipc/test_ipc.html":"nested ipc not working",
"dom/network/tests/test_networkstats_basics.html":"Will be fixed in bug 858005",
"dom/permission/tests/test_permission_basics.html":"https not working, bug 907770",