зеркало из https://github.com/mozilla/pluotsorbet.git
WIP of testing fs initialization
This commit is contained in:
Родитель
c158aa47ce
Коммит
41d335c017
|
@ -5,6 +5,7 @@
|
|||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1">
|
||||
<link rel="stylesheet" type="text/css" href="style/index.css">
|
||||
<script type="text/javascript" src="libs/load.js" defer></script>
|
||||
<script type="text/javascript" src="libs/promise-6.0.0.js" defer></script>
|
||||
<script type="text/javascript" src="libs/urlparams.js" defer></script>
|
||||
<script type="text/javascript" src="timer.js" defer></script>
|
||||
|
|
10
index.js
10
index.js
|
@ -3,16 +3,6 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
function loadScript(path) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
var element = document.createElement('script');
|
||||
element.setAttribute("type", "text/javascript");
|
||||
element.setAttribute("src", path);
|
||||
document.getElementsByTagName("head")[0].appendChild(element);
|
||||
element.onload = resolve;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Pre-load dependencies and then load the main page.
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||
|
||||
"use strict";
|
||||
|
||||
var initFS = new Promise(function(resolve, reject) {
|
||||
fs.init(resolve);
|
||||
}).then(function() {
|
||||
var fsPromises = [
|
||||
new Promise(function(resolve, reject) {
|
||||
fs.mkdir("/Persistent", resolve);
|
||||
}),
|
||||
|
||||
new Promise(function(resolve, reject) {
|
||||
fs.exists("/_main.ks", function(exists) {
|
||||
if (exists) {
|
||||
resolve();
|
||||
} else {
|
||||
load("certs/_main.ks", "blob").then(function(data) {
|
||||
fs.create("/_main.ks", data, function() {
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}),
|
||||
];
|
||||
|
||||
if (MIDP && MIDP.midletClassName == "RunTests") {
|
||||
fsPromises.push(
|
||||
new Promise(function(resolve, reject) {
|
||||
fs.exists("/_test.ks", function(exists) {
|
||||
if (exists) {
|
||||
resolve();
|
||||
} else {
|
||||
load("certs/_test.ks", "blob").then(function(data) {
|
||||
fs.create("/_test.ks", data, function() {
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
return Promise.all(fsPromises);
|
||||
});
|
|
@ -0,0 +1,29 @@
|
|||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||
|
||||
"use strict";
|
||||
|
||||
function load(file, responseType) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", file, true);
|
||||
xhr.responseType = responseType;
|
||||
xhr.onload = function () {
|
||||
resolve(xhr.response);
|
||||
};
|
||||
xhr.onerror = function() {
|
||||
reject();
|
||||
};
|
||||
xhr.send(null);
|
||||
});
|
||||
}
|
||||
|
||||
function loadScript(path) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
var element = document.createElement('script');
|
||||
element.setAttribute("type", "text/javascript");
|
||||
element.setAttribute("src", path);
|
||||
document.getElementsByTagName("head")[0].appendChild(element);
|
||||
element.onload = resolve;
|
||||
});
|
||||
}
|
|
@ -31,10 +31,12 @@
|
|||
<script type="text/javascript" src="instrument.js" defer></script>
|
||||
<script type="text/javascript" src="context.js" defer></script>
|
||||
<script type="text/javascript" src="jvm.js" defer></script>
|
||||
<script type="text/javascript" src="libs/load.js" defer></script>
|
||||
<script type="text/javascript" src="libs/zipfile.js" defer></script>
|
||||
<script type="text/javascript" src="libs/long.js" defer></script>
|
||||
<script type="text/javascript" src="libs/encoding.js" defer></script>
|
||||
<script type="text/javascript" src="libs/fs.js" defer></script>
|
||||
<script type="text/javascript" src="libs/fs-init.js" defer></script>
|
||||
<script type="text/javascript" src="libs/rusha.js" defer></script>
|
||||
<script type="text/javascript" src="libs/forge/util.js" defer></script>
|
||||
<script type="text/javascript" src="libs/forge/md5.js" defer></script>
|
||||
|
|
69
main.js
69
main.js
|
@ -3,31 +3,6 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
function load(file, responseType) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", file, true);
|
||||
xhr.responseType = responseType;
|
||||
xhr.onload = function () {
|
||||
resolve(xhr.response);
|
||||
};
|
||||
xhr.onerror = function() {
|
||||
reject();
|
||||
};
|
||||
xhr.send(null);
|
||||
});
|
||||
}
|
||||
|
||||
function loadScript(path) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
var element = document.createElement('script');
|
||||
element.setAttribute("type", "text/javascript");
|
||||
element.setAttribute("src", path);
|
||||
document.getElementsByTagName("head")[0].appendChild(element);
|
||||
element.onload = resolve;
|
||||
});
|
||||
}
|
||||
|
||||
// To launch the unit tests: ?main=RunTests
|
||||
// To launch the MIDP demo: ?main=com/sun/midp/main/MIDletSuiteLoader&midletClassName=HelloCommandMIDlet
|
||||
// To launch a JAR file: ?main=com/sun/midp/main/MIDletSuiteLoader&args=app.jar
|
||||
|
@ -60,50 +35,6 @@ if (urlParams.pushConn && urlParams.pushMidlet) {
|
|||
});
|
||||
}
|
||||
|
||||
var initFS = new Promise(function(resolve, reject) {
|
||||
fs.init(resolve);
|
||||
}).then(function() {
|
||||
var fsPromises = [
|
||||
new Promise(function(resolve, reject) {
|
||||
fs.mkdir("/Persistent", resolve);
|
||||
}),
|
||||
|
||||
new Promise(function(resolve, reject) {
|
||||
fs.exists("/_main.ks", function(exists) {
|
||||
if (exists) {
|
||||
resolve();
|
||||
} else {
|
||||
load("certs/_main.ks", "blob").then(function(data) {
|
||||
fs.create("/_main.ks", data, function() {
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}),
|
||||
];
|
||||
|
||||
if (MIDP.midletClassName == "RunTests") {
|
||||
fsPromises.push(
|
||||
new Promise(function(resolve, reject) {
|
||||
fs.exists("/_test.ks", function(exists) {
|
||||
if (exists) {
|
||||
resolve();
|
||||
} else {
|
||||
load("certs/_test.ks", "blob").then(function(data) {
|
||||
fs.create("/_test.ks", data, function() {
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
return Promise.all(fsPromises);
|
||||
});
|
||||
|
||||
// Mobile info gets accessed a lot, so we cache it on startup.
|
||||
var mobileInfo;
|
||||
var getMobileInfo = new Promise(function(resolve, reject) {
|
||||
|
|
|
@ -63,7 +63,17 @@ var expectedUnitTestResults = [
|
|||
{ name: "unknown pass", number: 0 }
|
||||
];
|
||||
|
||||
casper.test.begin("unit tests", 10 + gfxTests.length, function(test) {
|
||||
casper.test.begin("unit tests", 11 + gfxTests.length, function(test) {
|
||||
casper
|
||||
.start("http://localhost:8000/tests/fs/init-fs.html")
|
||||
.waitForText("DONE", function() {});
|
||||
|
||||
casper
|
||||
.thenOpen("http://localhost:8000/tests/fs/test-fs-init.html")
|
||||
.waitForText("DONE", function() {
|
||||
test.assertTextExists("DONE: 12 PASS, 0 FAIL", "test fs init");
|
||||
});
|
||||
|
||||
function basicUnitTests() {
|
||||
casper.waitForText("DONE", function() {
|
||||
var content = this.getPageContent();
|
||||
|
@ -91,7 +101,7 @@ casper.test.begin("unit tests", 10 + gfxTests.length, function(test) {
|
|||
});
|
||||
}
|
||||
casper
|
||||
.start("http://localhost:8000/index.html")
|
||||
.thenOpen("http://localhost:8000/index.html")
|
||||
.withFrame(0, basicUnitTests);
|
||||
|
||||
casper
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<script type="text/javascript" src="../../timer.js"></script>
|
||||
<script type="text/javascript" src="../../libs/load.js"></script>
|
||||
<script type="text/javascript" src="../../libs/fs.js"></script>
|
||||
<script type="text/javascript" src="../../libs/fs-init.js"></script>
|
||||
<script type="text/javascript">
|
||||
var MIDP = { midletClassName: "RunTests" };
|
||||
initFS.then(function() {
|
||||
document.body.appendChild(document.createTextNode("DONE"));
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -4,57 +4,17 @@
|
|||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<script type="text/javascript" src="../../timer.js"></script>
|
||||
<script type="text/javascript" src="../../libs/load.js"></script>
|
||||
<script type="text/javascript" src="fs-v1.js"></script>
|
||||
<script type="text/javascript" src="../../libs/fs-init.js"></script>
|
||||
<script type="text/javascript">
|
||||
initFS.then(function() {
|
||||
document.body.appendChild(document.createTextNode("DONE"));
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<script type="text/javascript">
|
||||
function load(file, responseType) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", file, true);
|
||||
xhr.responseType = responseType;
|
||||
xhr.onload = function () {
|
||||
resolve(xhr.response);
|
||||
};
|
||||
xhr.onerror = function() {
|
||||
reject();
|
||||
};
|
||||
xhr.send(null);
|
||||
});
|
||||
}
|
||||
|
||||
new Promise(function(resolve, reject) {
|
||||
fs.init(resolve);
|
||||
}).then(function() {
|
||||
return Promise.all([
|
||||
new Promise(function(resolve, reject) {
|
||||
fs.mkdir("/Persistent", resolve);
|
||||
}),
|
||||
|
||||
new Promise(function(resolve, reject) {
|
||||
load("../../certs/_main.ks", "blob").then(function(data) {
|
||||
fs.create("/_main.ks", data, function() {
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}),
|
||||
|
||||
new Promise(function(resolve, reject) {
|
||||
load("../../certs/_test.ks", "blob").then(function(data) {
|
||||
fs.create("/_test.ks", data, function() {
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}),
|
||||
]);
|
||||
}).then(function() {
|
||||
return new Promise(function(resolve, reject) {
|
||||
fs.storeSync(resolve);
|
||||
});
|
||||
}).then(function() {
|
||||
document.body.appendChild(document.createTextNode("DONE"));
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* vim: set shiftwidth=4 tabstop=4 autoindent cindent expandtab: */
|
||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||
|
||||
var casper = require('casper').create({
|
||||
verbose: true,
|
||||
logLevel: "debug",
|
||||
verbose: true,
|
||||
logLevel: "debug",
|
||||
});
|
||||
|
||||
casper.on('remote.message', function(message) {
|
||||
this.echo(message);
|
||||
this.echo(message);
|
||||
});
|
||||
|
||||
casper.start("http://localhost:8000/tests/fs/make-fs-v1.html");
|
||||
|
|
Загрузка…
Ссылка в новой задаче