Merge branch 'master' into native_elements

This commit is contained in:
Marco Castelluccio 2015-01-15 00:38:25 +01:00
Родитель 85a903f510 7b0b5e13a4
Коммит c09ff2d956
14 изменённых файлов: 143 добавлений и 25 удалений

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

@ -6,11 +6,16 @@ env:
before_script:
- "sh -e /etc/init.d/xvfb start"
- npm install casperjs
- wget https://ftp.mozilla.org/pub/mozilla.org/labs/j2me.js/slimerjs-0.10.0pre-2014-12-17.zip
- unzip -d /tmp slimerjs-0.10.0pre-2014-12-17.zip
- wget -P /tmp/j2me.js -N https://ftp.mozilla.org/pub/mozilla.org/labs/j2me.js/slimerjs-0.10.0pre-2014-12-17.zip
- unzip -d /tmp /tmp/j2me.js/slimerjs-0.10.0pre-2014-12-17.zip
- export PATH=$PATH:/tmp/slimerjs-0.10.0pre
- wget https://ftp.mozilla.org/pub/mozilla.org/xulrunner/releases/31.0/runtimes/xulrunner-31.0.en-US.linux-x86_64.tar.bz2
- tar x -C /tmp -f xulrunner-31.0.en-US.linux-x86_64.tar.bz2
- wget -P /tmp/j2me.js -N https://ftp.mozilla.org/pub/mozilla.org/xulrunner/releases/31.0/runtimes/xulrunner-31.0.en-US.linux-x86_64.tar.bz2
- tar x -C /tmp -f /tmp/j2me.js/xulrunner-31.0.en-US.linux-x86_64.tar.bz2
- export SLIMERJSLAUNCHER=/tmp/xulrunner/xulrunner
script:
- make test
sudo: false
cache:
directories:
- node_modules
- /tmp/j2me.js

Двоичные данные
img/icon-128.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 3.0 KiB

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

@ -441,6 +441,15 @@ DumbPipe.registerOpener("notification", function(message, sender) {
notification.onshow = function() {
sender({ type: "opened" });
};
notification.onclick = function() {
var request = navigator.mozApps.getSelf();
request.onsuccess = function() {
var app = request.result;
if (app) {
app.launch();
}
};
};
}
if (Notification.permission === "granted") {
@ -472,8 +481,8 @@ DumbPipe.registerOpener("notification", function(message, sender) {
}
});
DumbPipe.registerOpener("JARDownloader", function(message, sender) {
loadWithProgress(urlParams.downloadJAD, "text", function(jadData) {
DumbPipe.registerOpener("JARDownloader", function(url, sender) {
loadWithProgress(url, "text", function(jadData) {
try {
var manifest = {};
@ -494,7 +503,7 @@ DumbPipe.registerOpener("JARDownloader", function(message, sender) {
if (!jarURL.startsWith("http")) {
var jarName = jarURL.substring(jarURL.lastIndexOf("/") + 1);
jarURL = urlParams.downloadJAD.substring(0, urlParams.downloadJAD.lastIndexOf("/") + 1) + jarName;
jarURL = url.substring(0, url.lastIndexOf("/") + 1) + jarName;
}
loadWithProgress(jarURL, "arraybuffer", function(jarData) {
@ -515,3 +524,7 @@ DumbPipe.registerOpener("JARDownloader", function(message, sender) {
DumbPipe.registerOpener("windowOpen", function(message, sender) {
window.open(message);
});
DumbPipe.registerOpener("reload", function(message, sender) {
window.location.reload();
});

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

@ -41,7 +41,7 @@ var urlParams = (function() {
params[param[0]] = param[1];
});
params.args = (params.args || "").replace(".", "/", "g").split(",");
params.args = (params.args || "").split(",");
return params;
})();

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

@ -82,13 +82,13 @@ if (urlParams.jad) {
loadingPromises.push(load(urlParams.jad, "text").then(processJAD));
}
function performDownload(dialog, callback) {
function performDownload(url, dialog, callback) {
var dialogText = dialog.querySelector('h1.download-dialog-text');
dialogText.textContent = "Downloading " + MIDlet.name + "…";
var progressBar = dialog.querySelector('progress.pack-activity');
var sender = DumbPipe.open("JARDownloader", {}, function(message) {
var sender = DumbPipe.open("JARDownloader", url, function(message) {
switch (message.type) {
case "done":
DumbPipe.close(sender);
@ -121,7 +121,7 @@ function performDownload(dialog, callback) {
progressBar.style.display = '';
performDownload(dialog, callback);
performDownload(url, dialog, callback);
});
break;
@ -156,7 +156,7 @@ if (urlParams.downloadJAD) {
dialog.classList.add('visible');
document.body.appendChild(dialog);
performDownload(dialog, function(data) {
performDownload(urlParams.downloadJAD, dialog, function(data) {
dialog.parentElement.removeChild(dialog);
jvm.addPath("midlet.jar", data.jarData);

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

@ -21,9 +21,11 @@
"access": "readonly"
},
"mobilenetwork": {
"description:": "Required to verify your phone number"
"description": "Required to verify your phone number"
},
"browser": {
"description": "Required to improve performance"
},
"browser": {},
"audio-capture": {
"description": "Required to capture audio via getUserMedia"
},

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

@ -227,7 +227,39 @@ Native.create("com/sun/midp/security/Permissions.loadGroupPermissions.(Ljava/lan
Native.create("com/sun/midp/main/CldcPlatformRequest.dispatchPlatformRequest.(Ljava/lang/String;)Z", function(request) {
request = util.fromJavaString(request);
if (request.startsWith("http://") || request.startsWith("https://")) {
DumbPipe.close(DumbPipe.open("windowOpen", request));
if (request.endsWith(".jad")) {
// TODO: The download should start after the MIDlet has terminated its execution.
// Currently we're just updating right away because of #744.
var dialog = document.getElementById('download-progress-dialog').cloneNode(true);
dialog.style.display = 'block';
dialog.classList.add('visible');
document.body.appendChild(dialog);
performDownload(request, dialog, function(data) {
dialog.parentElement.removeChild(dialog);
Promise.all([
new Promise(function(resolve, reject) {
fs.remove("/midlet.jad", function() {
fs.create("/midlet.jad", new Blob([ data.jadData ]), resolve);
});
}),
new Promise(function(resolve, reject) {
fs.remove("/midlet.jar", function() {
fs.create("/midlet.jar", new Blob([ data.jarData ]), resolve);
});
}),
]).then(function() {
DumbPipe.close(DumbPipe.open("alert", "Update completed!"));
DumbPipe.close(DumbPipe.open("reload", {}));
});
});
return true;
} else {
DumbPipe.close(DumbPipe.open("windowOpen", request));
}
} else if (request.startsWith("x-contacts:add?number=")) {
new MozActivity({
name: "new",

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

@ -0,0 +1,8 @@
MIDlet-1: AMIDlet,,tests.jaddownloader.AMIDlet
MIDlet-Jar-Size: 2436
MIDlet-Jar-URL: tests.jar
MIDlet-Name: AMIDlet
MIDlet-Vendor: MIDlet Suite Vendor
MIDlet-Version: 3.0.0
MicroEdition-Configuration: CLDC-1.0
MicroEdition-Profile: MIDP-2.1

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

@ -3,6 +3,6 @@ MIDlet-Jar-Size: 2436
MIDlet-Jar-URL: http://localhost:8000/tests/tests.jar
MIDlet-Name: AMIDlet
MIDlet-Vendor: MIDlet Suite Vendor
MIDlet-Version: 1.0.0
MIDlet-Version: 2.0.0
MicroEdition-Configuration: CLDC-1.0
MicroEdition-Profile: MIDP-2.1

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

@ -110,7 +110,7 @@ public class RunTests extends MIDlet {
}
public void startApp() {
String arg = getAppProperty("arg-0");
String arg = getAppProperty("arg-0").replace('.', '/');
long then = JVM.monotonicTimeMillis();
@ -128,7 +128,7 @@ public class RunTests extends MIDlet {
System.err.println("can't find test " + arg);
}
arg = getAppProperty("arg-" + ++i);
arg = getAppProperty("arg-" + ++i).replace('.', '/');
}
} else {
for (int n = 0; n < Testlets.list.length; ++n) {

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

@ -311,29 +311,63 @@ casper.test.begin("unit tests", 14 + gfxTests.length, function(test) {
});
casper
.thenOpen("http://localhost:8000/index.html?downloadJAD=http://localhost:8000/tests/Manifest1.jad&midletClassName=tests.jaddownloader.AMIDlet&logConsole=web,page")
.thenOpen("http://localhost:8000/index.html?downloadJAD=http://localhost:8000/tests/Manifest1.jad&midletClassName=tests.jaddownloader.AMIDlet&logConsole=web,page&args=1.0.0")
.withFrame(0, function() {
casper.waitForText("DONE", function() {
test.assertTextExists("SUCCESS 3/3", "test JAD downloader");
test.assertTextExists("SUCCESS 3/3", "test JAD downloader - Download");
syncFS();
});
});
// Run the test a second time to ensure loading the JAR stored in the FS works correctly.
casper
.thenOpen("http://localhost:8000/index.html?downloadJAD=http://localhost:8000/tests/Manifest1.jad&midletClassName=tests.jaddownloader.AMIDlet&logConsole=web,page")
.thenOpen("http://localhost:8000/index.html?downloadJAD=http://localhost:8000/tests/Manifest1.jad&midletClassName=tests.jaddownloader.AMIDlet&logConsole=web,page&args=1.0.0")
.withFrame(0, function() {
casper.waitForText("DONE", function() {
test.assertTextExists("SUCCESS 3/3", "test JAD downloader");
test.assertTextExists("SUCCESS 3/3", "test JAD downloader - Load");
syncFS();
});
});
// Run the test that updates the MIDlet
casper
.thenOpen("http://localhost:8000/index.html?downloadJAD=http://localhost:8000/tests/Manifest2.jad&midletClassName=tests.jaddownloader.AMIDlet&logConsole=web,page")
.thenOpen("http://localhost:8000/index.html?downloadJAD=http://localhost:8000/tests/Manifest1.jad&midletClassName=tests.jaddownloader.AMIDletUpdater&logConsole=web,page")
.withFrame(0, function() {
var alertText = null;
casper.on('remote.alert', function onAlert(message) {
casper.removeListener('remote.alert', onAlert);
alertText = message;
});
casper.waitFor(function() {
return !!alertText;
}, function() {
test.assertEquals(alertText, "Update completed!");
syncFS();
});
});
// Verify that the update has been applied
casper
.thenOpen("http://localhost:8000/index.html?downloadJAD=http://localhost:8000/tests/Manifest1.jad&midletClassName=tests.jaddownloader.AMIDlet&logConsole=web,page&args=3.0.0")
.withFrame(0, function() {
casper.waitForText("DONE", function() {
test.assertTextExists("SUCCESS 3/3", "test JAD downloader");
test.assertTextExists("SUCCESS 3/3", "test JAD downloader - Load after update");
syncFS();
});
});
// Clear the FS before downloading another JAD
casper
.thenOpen("http://localhost:8000/tests/fs/delete-fs.html")
.waitForText("DONE");
casper
.thenOpen("http://localhost:8000/index.html?downloadJAD=http://localhost:8000/tests/Manifest2.jad&midletClassName=tests.jaddownloader.AMIDlet&logConsole=web,page&args=2.0.0")
.withFrame(0, function() {
casper.waitForText("DONE", function() {
test.assertTextExists("SUCCESS 3/3", "test JAD downloader - Download with absolute URL");
syncFS();
});
});

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

@ -7,7 +7,7 @@ public class AMIDlet extends midlets.TestMidlet {
try {
compare(getAppProperty("MIDlet-Name"), "AMIDlet");
compare(getAppProperty("MIDlet-Vendor"), "MIDlet Suite Vendor");
compare(getAppProperty("MIDlet-Version"), "1.0.0");
compare(getAppProperty("MIDlet-Version"), getAppProperty("arg-0"));
} catch (NullPointerException ex) {
fail(ex);
}

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

@ -0,0 +1,21 @@
package tests.jaddownloader;
import javax.microedition.midlet.MIDlet;
import javax.microedition.io.ConnectionNotFoundException;
public class AMIDletUpdater extends MIDlet {
public void startApp() {
try {
platformRequest("http://localhost:8000/tests/Manifest1Updated.jad");
} catch (ConnectionNotFoundException e) {
e.printStackTrace();
System.out.println("FAIL");
}
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
}

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

@ -40,3 +40,6 @@ mkdir $PACKAGE_DIR/tests
cp tests/tests.jar $PACKAGE_DIR/tests/.
cp tests/*.js $PACKAGE_DIR/tests/.
# copy icons
mkdir $PACKAGE_DIR/img
cp img/*.png $PACKAGE_DIR/img/.