mirror of
https://github.com/classilla/tenfourfox.git
synced 2024-09-11 02:56:06 +00:00
67 lines
1.9 KiB
HTML
67 lines
1.9 KiB
HTML
<!--
|
|
Any copyright is dedicated to the Public Domain.
|
|
http://creativecommons.org/publicdomain/zero/1.0/
|
|
-->
|
|
<!DOCTYPE HTML>
|
|
<html>
|
|
<!--
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=1126694
|
|
-->
|
|
<head>
|
|
<title>Test for device storage area listener API </title>
|
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
<script type="text/javascript" src="devicestorage_common.js"></script>
|
|
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
|
</head>
|
|
<body>
|
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1126694">Mozilla Bug 1126684</a>
|
|
<p id="display"></p>
|
|
<div id="content" style="display: none">
|
|
|
|
</div>
|
|
<pre id="test">
|
|
<script class="testbody" type="text/javascript">
|
|
|
|
devicestorage_setup(function () {
|
|
|
|
var XPCOMUtils = SpecialPowers.Cu.import("resource://gre/modules/XPCOMUtils.jsm").XPCOMUtils;
|
|
var Ci = SpecialPowers.Ci;
|
|
|
|
var volumeService = SpecialPowers.Cc["@mozilla.org/telephony/volume-service;1"].getService(Ci.nsIVolumeService);
|
|
|
|
var volName = "dummy-volume";
|
|
var mountPoint = "/data/local/tmp/dummy";
|
|
|
|
var storage;
|
|
if (navigator.deviceStorageAreaListener) {
|
|
ok (true, "got deviceStorageAreaListener")
|
|
}
|
|
|
|
navigator.deviceStorageAreaListener.addEventListener("storageareachanged", function (e) {
|
|
info("got storageareachanged event name:" + e.storageName + "\n");
|
|
info("operation:" + e.operation + "\n");
|
|
|
|
if (e.operation == "added") {
|
|
storage = navigator.getDeviceStorageByNameAndType(e.storageName, "sdcard");
|
|
ok (storage, "got storage");
|
|
volumeService.removeFakeVolume(volName);
|
|
}
|
|
else if (e.operation == "removed") {
|
|
ok (true, "got removal event");
|
|
SimpleTest.finish();
|
|
}
|
|
});
|
|
|
|
storage = navigator.getDeviceStorageByNameAndType(volName, "sdcard");
|
|
ok(!storage, "storage area doesn't exist");
|
|
|
|
volumeService.createFakeVolume(volName, mountPoint);
|
|
|
|
});
|
|
|
|
</script>
|
|
</pre>
|
|
</body>
|
|
</html>
|