зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 6ff483d6ba34 (bug 1172562) for timeouts in test_cache_clear_on_app_uninstall.html
This commit is contained in:
Родитель
0f9ea8b283
Коммит
a06a9d27a5
|
@ -1,29 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test app for bug 1172562</title>
|
||||
<script src='test.js'></script>
|
||||
<script type='application/javascript;version=1.7'>
|
||||
|
||||
function runTests() {
|
||||
return Promise.resolve()
|
||||
.then(() => { return navigator.serviceWorker.ready })
|
||||
.then((registration) => {
|
||||
return new Promise((resolve) => {
|
||||
var worker = registration.waiting || registration.active;
|
||||
worker.postMessage('read');
|
||||
navigator.serviceWorker.onmessage = (message) => {
|
||||
if (message.data.type == 'done') {
|
||||
ok(!message.data.cached, 'No cached data');
|
||||
resolve();
|
||||
}
|
||||
};
|
||||
});
|
||||
})
|
||||
.then(done);
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body onload='runTests()'>
|
||||
</body>
|
||||
</html>
|
|
@ -1,31 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test app for bug 1172562</title>
|
||||
<script src='test.js'></script>
|
||||
<script type='application/javascript;version=1.7'>
|
||||
|
||||
function runTests() {
|
||||
return Promise.resolve()
|
||||
.then(() => { return navigator.serviceWorker.ready })
|
||||
.then((registration) => {
|
||||
return new Promise((resolve) => {
|
||||
var worker = registration.waiting || registration.active;
|
||||
worker.postMessage('write');
|
||||
navigator.serviceWorker.onmessage = (message) => {
|
||||
if (message.data.type == 'written') {
|
||||
worker.postMessage('read');
|
||||
} else if (message.data.type == 'done') {
|
||||
ok(message.data.cached, 'Write success');
|
||||
resolve();
|
||||
}
|
||||
};
|
||||
});
|
||||
})
|
||||
.then(done);
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body onload='runTests()'>
|
||||
</body>
|
||||
</html>
|
|
@ -1,41 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test app for bug 1172562</title>
|
||||
<script type='application/javascript;version=1.7'>
|
||||
function ok(aCondition, aMessage) {
|
||||
if (aCondition) {
|
||||
alert('OK: ' + aMessage);
|
||||
} else {
|
||||
alert('KO: ' + aMessage);
|
||||
}
|
||||
}
|
||||
|
||||
function ready() {
|
||||
alert('READY');
|
||||
}
|
||||
|
||||
function registerServiceWorker() {
|
||||
return new Promise((resolve, reject) => {
|
||||
navigator.serviceWorker.ready.then(() => {
|
||||
ready();
|
||||
resolve();
|
||||
});
|
||||
navigator.serviceWorker.register('sw.js', {scope: '.'})
|
||||
.then(registration => {
|
||||
ok(true, 'service worker registered');
|
||||
})
|
||||
.catch(reject);
|
||||
});
|
||||
}
|
||||
|
||||
function runTests() {
|
||||
return Promise.resolve()
|
||||
.then(registerServiceWorker)
|
||||
.then(ready)
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body onload='runTests()'>
|
||||
</body>
|
||||
</html>
|
|
@ -1,5 +0,0 @@
|
|||
{
|
||||
"name": "App",
|
||||
"launch_path": "/index.html",
|
||||
"description": "Test app for bug 1172562"
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
Content-Type: application/manifest+json
|
|
@ -1,18 +0,0 @@
|
|||
self.addEventListener('message', (message) => {
|
||||
caches.open('acache').then((cache) => {
|
||||
if(message.data == 'write') {
|
||||
cache.add('aurl').then(() => {
|
||||
message.source.postMessage({
|
||||
type: 'written'
|
||||
});
|
||||
});
|
||||
} else if (message.data == 'read') {
|
||||
cache.match('aurl').then((result) => {
|
||||
message.source.postMessage({
|
||||
type: 'done',
|
||||
cached: !!result
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
|
@ -1,15 +0,0 @@
|
|||
function ok(aCondition, aMessage) {
|
||||
if (aCondition) {
|
||||
alert('OK: ' + aMessage);
|
||||
} else {
|
||||
alert('KO: ' + aMessage);
|
||||
}
|
||||
}
|
||||
|
||||
function ready() {
|
||||
alert('READY');
|
||||
}
|
||||
|
||||
function done() {
|
||||
alert('DONE');
|
||||
}
|
|
@ -23,7 +23,6 @@ support-files =
|
|||
test_cache_https.js
|
||||
large_url_list.js
|
||||
empty.html
|
||||
app/*
|
||||
|
||||
[test_cache.html]
|
||||
[test_cache_add.html]
|
||||
|
@ -41,8 +40,6 @@ support-files =
|
|||
skip-if = buildapp == 'b2g' # bug 1162353
|
||||
[test_cache_restart.html]
|
||||
[test_cache_shrink.html]
|
||||
[test_cache_clear_on_app_uninstall.html]
|
||||
skip-if = e10s # bug 1178685
|
||||
[test_cache_orphaned_cache.html]
|
||||
[test_cache_orphaned_body.html]
|
||||
[test_cache_untrusted.html]
|
||||
|
|
|
@ -1,163 +0,0 @@
|
|||
<!--
|
||||
Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
-->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Bug 1172562 - Clear QuotaManager storage when uninstalling an app</title>
|
||||
<script type='text/javascript' src='/tests/SimpleTest/SimpleTest.js'></script>
|
||||
<link rel='stylesheet' type='text/css' href='/tests/SimpleTest/test.css' />
|
||||
</head>
|
||||
<body onload='runTests()'>
|
||||
<p id='display'></p>
|
||||
<div id='content' style='display: none'></div>
|
||||
<pre id='test'></pre>
|
||||
<script class='testbody' type='application/javascript;version=1.7'>
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
const gOrigin = 'http://mochi.test:8888/tests/dom/cache/test/mochitest/app';
|
||||
const appManifestURL = gOrigin + '/manifest.webapp';
|
||||
let gApp;
|
||||
|
||||
function setup() {
|
||||
return new Promise((resolve, reject) => {
|
||||
SpecialPowers.setAllAppsLaunchable(true);
|
||||
SpecialPowers.pushPrefEnv({'set': [
|
||||
['dom.mozBrowserFramesEnabled', true],
|
||||
['dom.serviceWorkers.exemptFromPerDomainMax', true],
|
||||
['dom.serviceWorkers.enabled', true],
|
||||
['dom.serviceWorkers.testing.enabled', true],
|
||||
['dom.caches.enabled', true],
|
||||
]}, () => {
|
||||
SpecialPowers.pushPermissions([
|
||||
{ 'type': 'webapps-manage', 'allow': 1, 'context': document },
|
||||
{ 'type': 'browser', 'allow': 1, 'context': document },
|
||||
{ 'type': 'embed-apps', 'allow': 1, 'context': document }
|
||||
], () => {
|
||||
SpecialPowers.autoConfirmAppInstall(() => {
|
||||
SpecialPowers.autoConfirmAppUninstall(resolve);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function installApp() {
|
||||
return new Promise((resolve, reject) => {
|
||||
let req = navigator.mozApps.install(appManifestURL);
|
||||
req.onsuccess = function() {
|
||||
gApp = req.result;
|
||||
is(req.result.manifestURL, appManifestURL, 'app installed');
|
||||
if (req.result.installState == 'installed') {
|
||||
is(req.result.installState, 'installed', 'app downloaded');
|
||||
resolve()
|
||||
} else {
|
||||
req.result.ondownloadapplied = function() {
|
||||
is(req.result.installState, 'installed', 'app downloaded');
|
||||
resolve();
|
||||
}
|
||||
}
|
||||
}
|
||||
req.onerror = reject;
|
||||
});
|
||||
}
|
||||
|
||||
function launchApp() {
|
||||
if (!gApp) {
|
||||
ok(false, 'No test application to launch');
|
||||
return Promise.reject();
|
||||
}
|
||||
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;
|
||||
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');
|
||||
domParent.appendChild(iframe);
|
||||
SpecialPowers.wrap(iframe.contentWindow).location =
|
||||
gOrigin + gApp.manifest.launch_path;
|
||||
});
|
||||
}
|
||||
|
||||
function loadControlled(aUrl) {
|
||||
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;
|
||||
if (/OK/.exec(message)) {
|
||||
ok(true, "Message from app: " + message);
|
||||
} else if (/KO/.exec(message)) {
|
||||
ok(false, "Message from app: " + message);
|
||||
} else if (/DONE/.exec(message)) {
|
||||
ok(true, "Messaging from app complete");
|
||||
iframe.removeEventListener('mozbrowsershowmodalprompt', listener);
|
||||
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 =
|
||||
gOrigin + aUrl;
|
||||
});
|
||||
}
|
||||
|
||||
function loadBeforeClear() {
|
||||
return loadControlled('/before_clear.html');
|
||||
}
|
||||
|
||||
function loadAfterClear() {
|
||||
return loadControlled('/after_clear.html');
|
||||
}
|
||||
|
||||
function uninstallApp() {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!gApp) {
|
||||
return reject();
|
||||
}
|
||||
let req = navigator.mozApps.mgmt.uninstall(gApp);
|
||||
req.onsuccess = resolve;
|
||||
req.onerror = reject;
|
||||
});
|
||||
}
|
||||
|
||||
function runTests() {
|
||||
setup()
|
||||
.then(installApp)
|
||||
.then(launchApp)
|
||||
.then(loadBeforeClear)
|
||||
.then(uninstallApp)
|
||||
.then(installApp)
|
||||
.then(launchApp)
|
||||
.then(loadAfterClear)
|
||||
.then(uninstallApp)
|
||||
.then(SimpleTest.finish)
|
||||
.catch((e) => {
|
||||
ok(false, 'Unexpected error ' + e.target.error.name);
|
||||
SimpleTest.finish();
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
<div id='container'></div>
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче