Bug 777101 - DeviceStorage - Add onchange notifications test. r=khuey
authorDoug Turner <dougt@dougt.org>
Fri, 17 Aug 2012 19:43:00 -0700
changeset 102704 c7934a5efa2cb5e5994c86eb893a55f5f13e39dc
parent 102703 6d5892177f44dbee1349b42bb5a3d64ff6bdcde6
child 102705 77d2640d9892851b26fe4f531b6cb58f19d1a0bc
push id23303
push userryanvm@gmail.com
push dateSat, 18 Aug 2012 11:22:19 +0000
treeherdermozilla-central@9c48df21d744 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey
bugs777101
milestone17.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 777101 - DeviceStorage - Add onchange notifications test. r=khuey
dom/devicestorage/test/Makefile.in
dom/devicestorage/test/test_watch.html
--- a/dom/devicestorage/test/Makefile.in
+++ b/dom/devicestorage/test/Makefile.in
@@ -15,12 +15,13 @@ MOCHITEST_FILES	= \
 		test_basic.html \
 		test_enumerate.html \
 		test_enumerateMultipleContinue.html \
 		test_overwrite.html \
 		test_dotdot.html \
 		test_enumerateOptions.html \
 		test_lastModificationFilter.html \
 		test_stat.html \
+		test_watch.html \
 		devicestorage_common.js \
 		$(NULL)
 
 include $(topsrcdir)/config/rules.mk
new file mode 100644
--- /dev/null
+++ b/dom/devicestorage/test/test_watch.html
@@ -0,0 +1,72 @@
+<!--
+  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=717103
+-->
+<head>
+  <title>Test for the device storage 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=717103">Mozilla Bug 717103</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+  
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+devicestorage_setup();
+
+var gFileName = randomFilename(20);
+
+function addSuccess(e) {
+}
+
+function addError(e) {
+  ok(false, "addError was called : " + e.target.error.name);
+  devicestorage_cleanup();
+}
+
+function onChange(e) {
+
+  dump("we saw: " + e.path);
+
+  if (e.path == gFileName) {
+    ok(true, "we saw the file get created");
+    storage.removeEventListener("change", onChange);
+    devicestorage_cleanup();
+  }
+  else {
+    // we may see other file changes during the test, and
+    // that is completely ok
+  }
+}
+
+function makeFile() {
+  request = storage.addNamed(createRandomBlob(), gFileName);
+  ok(request, "Should have a non-null request");
+
+  request.onsuccess = addSuccess;
+  request.onerror = addError;
+}
+
+var storage = navigator.getDeviceStorage("testing");
+ok(navigator.getDeviceStorage, "Should have getDeviceStorage");
+storage.addEventListener("change", onChange);
+
+// since addEventListener is async, we have to wait until
+// it's definitely done before we make the file.
+setTimeout(makeFile,100);
+
+</script>
+</pre>
+</body>
+</html>
+