Bug 1126694 - Test case. r=dhylands
authorKershaw Chang <kechang@mozilla.com>
Mon, 27 Apr 2015 19:17:00 +0200
changeset 273708 c5d30567f41915f45a4864472b9ee030241ce1e8
parent 273707 aaa4487657420dfdade7210a7599e07bcf52d2be
child 273709 b41ebad8dbe7290febcfff30d038cb2f5fc4e328
push id863
push userraliiev@mozilla.com
push dateMon, 03 Aug 2015 13:22:43 +0000
treeherdermozilla-release@f6321b14228d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdhylands
bugs1126694
milestone40.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1126694 - Test case. r=dhylands
dom/devicestorage/ipc/ipc.json
dom/devicestorage/test/mochitest.ini
dom/devicestorage/test/test_storageAreaListener.html
--- a/dom/devicestorage/ipc/ipc.json
+++ b/dom/devicestorage/ipc/ipc.json
@@ -1,7 +1,8 @@
 {
 "runtests":{
 },
 "excludetests":{
-    "dom/devicestorage/test/test_dirs.html":"excluded"
+    "dom/devicestorage/test/test_dirs.html":"excluded",
+    "dom/devicestorage/test/test_storageAreaListener.html":"excluded"
    }
 }
--- a/dom/devicestorage/test/mochitest.ini
+++ b/dom/devicestorage/test/mochitest.ini
@@ -19,16 +19,18 @@ support-files = devicestorage_common.js
 [test_freeSpace.html]
 [test_lastModificationFilter.html]
 [test_overrideDir.html]
 [test_overwrite.html]
 [test_sanity.html]
 [test_usedSpace.html]
 [test_watch.html]
 [test_watchOther.html]
+[test_storageAreaListener.html]
+skip-if = toolkit != 'gonk'
 
 # FileSystem API tests
 [test_fs_basic.html]
 [test_fs_createDirectory.html]
 [test_fs_get.html]
 [test_fs_remove.html]
 [test_fs_createFile.html]
 [test_fs_appendFile.html]
new file mode 100644
--- /dev/null
+++ b/dom/devicestorage/test/test_storageAreaListener.html
@@ -0,0 +1,61 @@
+<!--
+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()
+
+	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");
+			devicestorage_cleanup();
+		}
+	});
+
+	volumeService.createFakeVolume(volName, mountPoint);
+
+</script>
+</pre>
+</body>
+</html>