Skip to content
This repository has been archived by the owner on Oct 12, 2021. It is now read-only.

Commit

Permalink
Merge branch 'develop' into feature/bug-689299-update-api
Browse files Browse the repository at this point in the history
  • Loading branch information
ianb committed Oct 5, 2011
2 parents 35982ab + 0f1573a commit ee31239
Show file tree
Hide file tree
Showing 20 changed files with 192 additions and 66 deletions.
12 changes: 7 additions & 5 deletions .gitmodules
Expand Up @@ -6,10 +6,12 @@
path = site/tests/jstestnet
url = git://github.com/kumar303/jstestnet.git

[submodule "icongrid"]
path = icongrid
url = http://github.com/mozilla/icongrid.git
[submodule "site/tests/jstestnetlib"]
path = site/tests/jstestnetlib
url = https://github.com/kumar303/jstestnetlib.git
[submodule "site/tests/serverjs/djangode"]
path = site/tests/serverjs/djangode
url = https://github.com/simonw/djangode.git

[submodule "site/icongrid"]
path = site/icongrid
url = http://github.com/mozilla/icongrid.git
url = https://github.com/mozilla/djangode.git
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -16,7 +16,7 @@ oauthorizer := $(TOPSRCDIR)/deps/oauthorizer
openwebapps := $(TOPSRCDIR)/addons/jetpack

#cfx_args := --pkgdir=$(TOPSRCDIR) $(profile) --package-path=$(oauthorizer) --package-path=$(openwebapps) --binary-args="-console -purgecaches"
cfx_args := --pkgdir=$(openwebapps) $(profile) --package-path=$(oauthorizer) --binary-args="-console -purgecaches"
cfx_args := --pkgdir=$(openwebapps) $(profile) --package-path=$(oauthorizer) --binary-args="-console -purgecaches $(BINARYARGS)"

xpi_name := openwebapps.xpi

Expand Down
8 changes: 6 additions & 2 deletions addons/jetpack/data/servicesapi.js
Expand Up @@ -63,10 +63,14 @@ self.port.on("owa.service.invoke", function(args) {
activity.postResult = function postResult(result) {
self.port.emit(activity.success, result);
}
activity.postException = function postException(exc) {
var postException = activity.postException = function postException(exc) {
self.port.emit(activity.error, exc);
}
activities[activity.action+"/"+activity.message].callback(activity, credentials);
try {
activities[activity.action+"/"+activity.message].callback(activity, credentials);
} catch (ex) {
postException({code: 'runtime_error', message: ex});
}
});

unsafeWindow.navigator.mozApps.services = window.navigator.mozApps.services;
1 change: 1 addition & 0 deletions addons/jetpack/lib/main.js
Expand Up @@ -82,6 +82,7 @@ function openwebapps(win, getUrlCB) {
// TODO: Figure out a way to do this without waiting for 500ms.
// Also, intercept document loads that don't open in a new tab
// (this should be done in the content-document-global-created observer?)
let self = this;
win.gBrowser.tabContainer.addEventListener("TabOpen", function(e) {
self._window.setTimeout(function(e) {
if (e.target.pinned) return;
Expand Down
15 changes: 9 additions & 6 deletions addons/jetpack/lib/services.js
Expand Up @@ -175,6 +175,9 @@ MediatorPanel.prototype = {
*/
onOWASuccess: function(msg) {
this.panel.hide();
// the mediator might have seen a failure but offered its own UI to
// retry - so hide any old error notifications.
this.hideErrorNotification();
if (this.successCB)
this.successCB(msg);
},
Expand All @@ -183,9 +186,9 @@ MediatorPanel.prototype = {
this.panel.hide();
},

onOWAFailure: function(msg) {
console.error("mediator reported invocation error:", msg)
this.showErrorNotification(msg);
onOWAFailure: function(errob) {
console.error("mediator reported invocation error:", errob.message)
this.showErrorNotification(errob);
},

onOWAReady: function(msg) {
Expand Down Expand Up @@ -334,12 +337,12 @@ MediatorPanel.prototype = {
// Check that we aren't already displaying our notification
if (!notification) {
let message;
if (data && data.msg)
message = data.msg;
if (data && data.message)
message = data.message;
else if (this.mediator && this.mediator.notificationErrorText)
message = this.mediator.notificationErrorText;
else
message = "42";
message = "There was an error performing this action";

let self = this;
buttons = [{
Expand Down
7 changes: 6 additions & 1 deletion addons/jetpack/test/apps/basic/basic.js
Expand Up @@ -8,9 +8,14 @@ navigator.mozApps.services.registerHandler('test.basic', "echoArgs",

navigator.mozApps.services.registerHandler('test.basic', "testErrors",
function(activity, credentials) {
dump("Got testErrors\n")
activity.postException({code: "testable_error", message: "a testable error"});
}
);

navigator.mozApps.services.registerHandler('test.basic', "testErrorsThrown",
function(activity, credentials) {
throw "a thrown error";
}
);

navigator.mozApps.services.ready();
31 changes: 24 additions & 7 deletions addons/jetpack/test/test-services.js
Expand Up @@ -117,29 +117,34 @@ exports.test_invoke_twice = function(test) {
}

// Error tests.
TestMediatorError = {
url: getTestUrl("apps/testable_mediator.html"),
contentScript:

function makeErrorTestContentScript(methodName) {
return "" +
"window.navigator.mozApps.mediation.ready(function(activity, services) {" +
" let service = services[0];" +
// XXX - why is unsafeWindow needed here???
" unsafeWindow.document.getElementById('servicebox').appendChild(service.iframe);" +
" service.on('ready', function() {" +
" service.call('testErrors', activity.data, function(result) {" +
" service.call('" + methodName + "', activity.data, function(result) {" +
" self.port.emit('owa.success', {code: 'test_failure', msg: 'unexpected success callback'});" +
" }, function(errob) {" +
" self.port.emit('owa.success', errob);" +
" });" +
" });" +
"});"
}

TestMediatorError = {
url: getTestUrl("apps/testable_mediator.html"),
contentScript: makeErrorTestContentScript("testErrors")
};

// A helper for the error tests.
function testError(test, errchecker) {
function testError(test, mediator, errchecker) {
test.waitUntilDone();
installTestApp(test, "apps/basic/basic.webapp", function() {
let services = getOWA()._services;
services.registerMediator("test.basic", TestMediatorError);
services.registerMediator("test.basic", mediator);
let panel = services.get(
getContentWindow(),
{action:"test.basic", data:{}}, // simulate an activity
Expand All @@ -158,10 +163,22 @@ function testError(test, errchecker) {
}

exports.test_invoke_error = function(test) {
testError(test, function(errob) {
testError(test, TestMediatorError, function(errob) {
test.assertEqual(errob.code, "testable_error");
test.assertEqual(errob.message, "a testable error");
test.done();
});
};

TestMediatorErrorThrown = {
url: getTestUrl("apps/testable_mediator.html"),
contentScript: makeErrorTestContentScript("testErrorsThrown")
};

exports.test_invoke_error_thrown = function(test) {
testError(test, TestMediatorErrorThrown, function(errob) {
test.assertEqual(errob.code, "runtime_error");
test.assertEqual(errob.message, "a thrown error");
test.done();
});
};
40 changes: 17 additions & 23 deletions site/css/jibe.css
Expand Up @@ -27,27 +27,21 @@ body {
display: block;
}

.app {
cursor: pointer;
margin: 10px;
font-size: 0.7em;
display: inline-block;
border: solid white 1px;
border-radius: 5px 5px 5px 5px;
}

.app:hover {
border: solid black 1px;
border-radius: 5px 5px 5px 5px;
}

.app img {
width: 80px;
height: 80px;
padding: 10px;
background-color: #F2F2F2;
background-image: -moz-linear-gradient(center top , #FFFFFF 0%, #F2F2F2 100%);
border: 1px solid #BBBBBB;
border-radius: 5px 5px 5px 5px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25) inset;
/*overriding icongrid.css*/
.icon {
padding: 8px;
position: relative;
width: 50%;
height: 50%;
margin-top:20%;
margin-left: auto;
margin-right: auto;

-moz-border-radius: 10%;
-webkit-border-radius: 10%;
border-radius: 10%;
background-color: #EEEEEE;
-webkit-box-shadow: inset 1px 1px 3px 1px #cccccc;
-moz-box-shadow: inset 1px 1px 3px 1px #cccccc;
box-shadow: inset 1px 1px 3px 1px #cccccc;
}
1 change: 0 additions & 1 deletion site/icongrid
Submodule icongrid deleted from eadff7
1 change: 1 addition & 0 deletions site/icongrid
6 changes: 3 additions & 3 deletions site/index.html
Expand Up @@ -9,11 +9,11 @@
<title dir="ltr">Jibe - The Dashboard that Syncs</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Marvel:400,700" type="text/css">
<link rel="stylesheet" media="screen" href="css/jibe.css" >
<link rel="stylesheet" media="screen" href="icongrid/icongrid.css" >
<link rel="stylesheet" media="screen" href="css/jibe.css" >

<script src="jquery-1.4.2.min.js" type="text/javascript"></script>
<script src="icongrid/base32.js" type="text/javascript"></script>
<script src="icongrid/jquery-1.4.2.min.js" type="text/javascript"></script>
<script src="icongrid/icongrid.js" type="text/javascript"></script>

<script src="https://myapps.mozillalabs.com/jsapi/include.js" type="text/javascript"></script>
Expand All @@ -22,7 +22,7 @@
<div id="content">
<div id="dashboard">
<p class="msg">Click to launch:</p>
<div id="apps" class="dashboardclipper well" style="width:600px; height:300px;">
<div id="apps" class="dashboardclipper well" style="width:800px; height:500px;">
</div>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions site/jquery-1.4.2.min.js
2 changes: 1 addition & 1 deletion site/js/jibe.js
Expand Up @@ -97,7 +97,7 @@ $(document).ready(function() {
};

var grid = $("#apps");
var gridLayout = new GridLayout(grid.width(), grid.height(), 4, 2);
var gridLayout = new GridLayout(grid.width(), grid.height(), 5, 3);
var gridDash = new IconGrid("appDashboard", grid, appData, gridLayout);
gridDash.initialize();
gridDash.refresh();
Expand Down
26 changes: 13 additions & 13 deletions site/tests/base.html
Expand Up @@ -22,22 +22,22 @@
<script type="text/javascript">
function param(name)
{
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^\\?&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( window.location.href );
if( results == null )
return "";
else
return results[1];
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^\\?&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( window.location.href );
if( results == null )
return "";
else
return results[1];
}

if (param("runnerType") == "jstestnet") {
var headID = document.getElementsByTagName("head")[0];
var newScript = document.createElement('script');
newScript.type = 'text/javascript';
newScript.src = '/tests/jstestnet/adapter/jstestnet.js';
headID.appendChild(newScript);
var headID = document.getElementsByTagName("head")[0];
var newScript = document.createElement('script');
newScript.type = 'text/javascript';
newScript.src = '/tests/jstestnet/adapter/jstestnet.js';
headID.appendChild(newScript);
}
</script>

Expand Down
2 changes: 1 addition & 1 deletion site/tests/doctestjs
Submodule doctestjs updated 2 files
+68 −27 doctest.js
+48 −0 index.html
2 changes: 1 addition & 1 deletion site/tests/jstestnet
1 change: 1 addition & 0 deletions site/tests/jstestnetlib
Submodule jstestnetlib added at c815ca
2 changes: 1 addition & 1 deletion site/tests/run.js
Expand Up @@ -331,7 +331,7 @@ dirs.forEach(function(dirObj) {

});
function serverCreated(name) {
console.log(" " + name + ": " + formatLink(name));
console.log(" " + name + ": " + formatLink(name));
}

function getSpecs() {
Expand Down
25 changes: 25 additions & 0 deletions site/tests/scripts/jenkins_install.txt
@@ -0,0 +1,25 @@
# Update System
echo 'System Update'
apt-get update
echo 'Update completed'
apt-get install git-core curl python-software-properties
# Install Node.js
echo 'Install Node.js'
wget http://nodejs.org/dist/node-v0.4.12.tar.gz
tar -zxvf node-v0.4.12.tar.gz
cd node-v0.4.12/
./configure && make && make install

echo 'Node.js install completed'
# Install Node Package Manager
echo 'Install Node Package Manager'
curl http://npmjs.org/install.sh | sudo sh
echo 'NPM install completed'
# Install Forever
echo 'Install Forever'
npm config set registry = "http://registry.npmjs.org/"
npm install forever -g
echo 'Forever install completed'

echo '####Virtual Env Install####'
easy_install virtualenv fudge psutil
30 changes: 30 additions & 0 deletions site/tests/scripts/run_jstests.py
@@ -0,0 +1,30 @@
"""
A wrapper around nosetests to run JavaScript tests in a CI environment.
Example::
python run_jstests.py --with-xunit \
--with-jstests \
--jstests-server http://jstestnet.farmdev.com/ \
--jstests-suite zamboni --jstests-browsers firefox
"""
import os
import site
import subprocess

ROOT = os.path.join(os.path.dirname(__file__), '..')

site.addsitedir(os.path.join(ROOT, 'vendor'))
site.addsitedir(os.path.join(ROOT, 'vendor/lib/python'))

from jstestnetlib.noseplugins import JSTests, DjangoServPlugin
import nose


def main():
nose.main(addplugins=[DjangoServPlugin(ROOT), JSTests()])


if __name__ == '__main__':
main()

0 comments on commit ee31239

Please sign in to comment.