Bug 1171285 - Part 2: Fix test_app_protocol.html to finish both index.html and controlled.html tests; r=jdm

This commit is contained in:
Ehsan Akhgari 2015-06-03 20:51:09 -04:00
Родитель 8fa914ff17
Коммит ca699d4bcb
3 изменённых файлов: 10 добавлений и 7 удалений

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

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

@ -7,7 +7,6 @@
function registerServiceWorker() {
return new Promise((resolve, reject) => {
navigator.serviceWorker.ready.then(() => {
ready();
resolve();
});
navigator.serviceWorker.register('sw.js', {scope: '.'})
@ -22,7 +21,7 @@ function runTests() {
return Promise.resolve()
.then(() => { return testFetchAppResource('networkresponse'); })
.then(registerServiceWorker)
.then(done);
.then(ready);
}
</script>
</head>

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

@ -22,7 +22,6 @@ const appManifestURL =
let gApp;
function setup() {
info('Setting up');
return new Promise((resolve, reject) => {
SpecialPowers.setAllAppsLaunchable(true);
SpecialPowers.pushPrefEnv({'set': [
@ -75,9 +74,15 @@ function launchApp() {
iframe.setAttribute('mozapp', gApp.manifestURL);
iframe.addEventListener('mozbrowsershowmodalprompt', function listener(e) {
let message = e.detail.message;
if (/READY/.exec(message)) {
if (/OK/.exec(message)) {
ok(true, "Message from app: " + message);
} else if (/KO/.exec(message)) {
ok(false, "Message from app: " + message);
} else if (/READY/.exec(message)) {
ok(true, "Message from app: " + message);
resolve();
} else {
ok(false, "Unexpected message received: " + message);
}
}, false);
let domParent = document.getElementById('container');
@ -88,14 +93,12 @@ function launchApp() {
}
function loadControlled() {
info("reloading");
return new Promise((resolve, reject) => {
let iframe = document.createElement('iframe');
iframe.setAttribute('mozbrowser', 'true');
iframe.setAttribute('mozapp', gApp.manifestURL);
iframe.addEventListener('mozbrowsershowmodalprompt', function listener(e) {
let message = e.detail.message;
info(message);
if (/OK/.exec(message)) {
ok(true, "Message from app: " + message);
} else if (/KO/.exec(message)) {
@ -106,13 +109,14 @@ function loadControlled() {
let domParent = document.getElementById('container');
domParent.removeChild(iframe);
resolve();
} else {
ok(false, "Unexpected message received: " + message);
}
}, false);
let domParent = document.getElementById('container');
domParent.appendChild(iframe);
SpecialPowers.wrap(iframe.contentWindow).location =
gApp.origin + '/controlled.html';
info("reloaded");
});
}