mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-26 10:27:32 +09:00
Issue #1263 - Part 2: Remove DiskSpaceWatcher tests
This commit is contained in:
parent
92b01bf08a
commit
3bfa0a4c34
11 changed files with 0 additions and 1011 deletions
|
|
@ -79,8 +79,6 @@ support-files =
|
|||
[test_fallback.html]
|
||||
[test_foreign.html]
|
||||
[test_identicalManifest.html]
|
||||
[test_lowDeviceStorage.html]
|
||||
[test_lowDeviceStorageDuringUpdate.html]
|
||||
[test_missingFile.html]
|
||||
[test_missingManifest.html]
|
||||
[test_noManifest.html]
|
||||
|
|
|
|||
|
|
@ -1,91 +0,0 @@
|
|||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>Low device storage</title>
|
||||
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="/tests/dom/tests/mochitest/ajax/offline/offlineTests.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
/**
|
||||
* This test checks that an offline cache update scheduled *after* a low device
|
||||
* storage situation appears is canceled. It basically does:
|
||||
*
|
||||
* 1. Notifies to the offline cache update service about a fake
|
||||
* low device storage situation.
|
||||
* 2. Schedules an update and observes for its notifications.
|
||||
* 3. We are supposed to receive an error event notifying about the cancelation
|
||||
* of the update because of the low storage situation.
|
||||
* 4. Notifies to the offline cache update service that we've recovered from
|
||||
* the low storage situation.
|
||||
*/
|
||||
|
||||
var updateService = SpecialPowers.Cc['@mozilla.org/offlinecacheupdate-service;1']
|
||||
.getService(Ci.nsIOfflineCacheUpdateService);
|
||||
|
||||
var obs = SpecialPowers.Cc["@mozilla.org/observer-service;1"]
|
||||
.getService(SpecialPowers.Ci.nsIObserverService);
|
||||
|
||||
var errorReceived = false;
|
||||
|
||||
var systemPrincipal = SpecialPowers.Services.scriptSecurityManager.getSystemPrincipal();
|
||||
|
||||
function finish() {
|
||||
obs.notifyObservers(updateService, "disk-space-watcher", "free");
|
||||
|
||||
OfflineTest.teardownAndFinish();
|
||||
}
|
||||
|
||||
if (OfflineTest.setup()) {
|
||||
obs.notifyObservers(updateService, "disk-space-watcher", "full");
|
||||
|
||||
var updateObserver = {
|
||||
updateStateChanged: function (aUpdate, aState) {
|
||||
switch(aState) {
|
||||
case Ci.nsIOfflineCacheUpdateObserver.STATE_ERROR:
|
||||
errorReceived = true;
|
||||
OfflineTest.ok(true, "Expected error. Update canceled");
|
||||
break;
|
||||
case Ci.nsIOfflineCacheUpdateObserver.STATE_FINISHED:
|
||||
aUpdate.removeObserver(this);
|
||||
OfflineTest.ok(errorReceived,
|
||||
"Finished after receiving the expected error");
|
||||
finish();
|
||||
break;
|
||||
case Ci.nsIOfflineCacheUpdateObserver.STATE_NOUPDATE:
|
||||
aUpdate.removeObserver(this);
|
||||
OfflineTest.ok(false, "No update");
|
||||
finish();
|
||||
break;
|
||||
case Ci.nsIOfflineCacheUpdateObserver.STATE_DOWNLOADING:
|
||||
case Ci.nsIOfflineCacheUpdateObserver.STATE_ITEMSTARTED:
|
||||
case Ci.nsIOfflineCacheUpdateObserver.STATE_ITEMPROGRESS:
|
||||
aUpdate.removeObserver(this);
|
||||
OfflineTest.ok(false, "The update was supposed to be canceled");
|
||||
finish();
|
||||
break;
|
||||
}
|
||||
},
|
||||
applicationCacheAvailable: function() {}
|
||||
};
|
||||
|
||||
var manifest = "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/simpleManifest.cacheManifest";
|
||||
var ioService = Cc["@mozilla.org/network/io-service;1"]
|
||||
.getService(Ci.nsIIOService);
|
||||
var manifestURI = ioService.newURI(manifest, null, null);
|
||||
var documentURI = ioService.newURI(document.documentURI, null, null);
|
||||
var update = updateService.scheduleUpdate(manifestURI, documentURI, systemPrincipal, window);
|
||||
update.addObserver(updateObserver, false);
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
</script>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
<html xmlns="http://www.w3.org/1999/xhtml" manifest="http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/simpleManifest.cacheManifest">
|
||||
<head>
|
||||
<title>Low device storage during update</title>
|
||||
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="/tests/dom/tests/mochitest/ajax/offline/offlineTests.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
/**
|
||||
* This test checks that an offline cache update is canceled when a low device
|
||||
* storage condition is detected during the update.
|
||||
*/
|
||||
|
||||
var updateService = Cc['@mozilla.org/offlinecacheupdate-service;1']
|
||||
.getService(Ci.nsIOfflineCacheUpdateService);
|
||||
|
||||
var obs = SpecialPowers.Cc["@mozilla.org/observer-service;1"]
|
||||
.getService(SpecialPowers.Ci.nsIObserverService);
|
||||
|
||||
function finish() {
|
||||
obs.notifyObservers(updateService, "disk-space-watcher", "free");
|
||||
|
||||
OfflineTest.teardownAndFinish();
|
||||
}
|
||||
|
||||
function onError() {
|
||||
OfflineTest.ok(true, "Expected error: Update canceled");
|
||||
finish();
|
||||
}
|
||||
|
||||
function onUnexpectedEvent() {
|
||||
OfflineTest.ok(false, "The update was supposed to be canceled");
|
||||
finish();
|
||||
}
|
||||
|
||||
function onChecking() {
|
||||
obs.notifyObservers(updateService, "disk-space-watcher", "full");
|
||||
}
|
||||
|
||||
if (OfflineTest.setup()) {
|
||||
applicationCache.onerror = OfflineTest.priv(onError);
|
||||
applicationCache.onprogress = OfflineTest.priv(onUnexpectedEvent);
|
||||
applicationCache.oncached = OfflineTest.priv(onUnexpectedEvent);
|
||||
applicationCache.onchecking = OfflineTest.priv(onChecking);
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
</script>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -47,6 +47,5 @@ skip-if = toolkit == 'android' #TIMED_OUT
|
|||
skip-if = toolkit == 'android' #TIMED_OUT
|
||||
[test_localStorageReplace.html]
|
||||
skip-if = toolkit == 'android'
|
||||
[test_lowDeviceStorage.html]
|
||||
[test_storageConstructor.html]
|
||||
[test_localStorageSessionPrefOverride.html]
|
||||
|
|
|
|||
|
|
@ -1,76 +0,0 @@
|
|||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>Test localStorage usage while in a low device storage situation</title>
|
||||
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="localStorageCommon.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
/*
|
||||
This test does the following:
|
||||
- Stores an item in localStorage.
|
||||
- Checks the stored value.
|
||||
- Emulates a low device storage situation.
|
||||
- Gets the stored item again.
|
||||
- Removes the stored item.
|
||||
- Fails storing a new value.
|
||||
- Emulates recovering from a low device storage situation.
|
||||
- Stores a new value.
|
||||
- Checks the stored value.
|
||||
*/
|
||||
|
||||
function lowDeviceStorage(lowStorage) {
|
||||
var data = lowStorage ? "full" : "free";
|
||||
os().notifyObservers(null, "disk-space-watcher", data);
|
||||
}
|
||||
|
||||
function startTest() {
|
||||
// Add a test item.
|
||||
localStorage.setItem("item", "value");
|
||||
is(localStorage.getItem("item"), "value", "getItem()");
|
||||
|
||||
// Emulates a low device storage situation.
|
||||
lowDeviceStorage(true);
|
||||
|
||||
// Checks that we can still access to the stored item.
|
||||
is(localStorage.getItem("item"), "value",
|
||||
"getItem() during a device storage situation");
|
||||
|
||||
// Removes the stored item.
|
||||
localStorage.removeItem("item");
|
||||
is(localStorage.getItem("item"), null,
|
||||
"getItem() after removing the item");
|
||||
|
||||
// Fails storing a new item.
|
||||
try {
|
||||
localStorage.setItem("newItem", "value");
|
||||
ok(false, "Storing a new item is expected to fail");
|
||||
} catch(e) {
|
||||
ok(true, "Got an expected exception " + e);
|
||||
} finally {
|
||||
is(localStorage.getItem("newItem"), null,
|
||||
"setItem while device storage is low");
|
||||
}
|
||||
|
||||
// Emulates recovering from a low device storage situation.
|
||||
lowDeviceStorage(false);
|
||||
|
||||
// Add a test item after recovering from the low device storage situation.
|
||||
localStorage.setItem("newItem", "value");
|
||||
is(localStorage.getItem("newItem"), "value",
|
||||
"getItem() with available storage");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
</script>
|
||||
|
||||
</head>
|
||||
|
||||
<body onload="startTest();">
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue