summaryrefslogtreecommitdiffstats
path: root/netwerk/test/unit/test_bug654926.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /netwerk/test/unit/test_bug654926.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'netwerk/test/unit/test_bug654926.js')
-rw-r--r--netwerk/test/unit/test_bug654926.js88
1 files changed, 88 insertions, 0 deletions
diff --git a/netwerk/test/unit/test_bug654926.js b/netwerk/test/unit/test_bug654926.js
new file mode 100644
index 000000000..83fd7286f
--- /dev/null
+++ b/netwerk/test/unit/test_bug654926.js
@@ -0,0 +1,88 @@
+var _PSvc;
+function get_pref_service() {
+ if (_PSvc)
+ return _PSvc;
+
+ return _PSvc = Cc["@mozilla.org/preferences-service;1"].
+ getService(Ci.nsIPrefBranch);
+}
+
+function gen_1MiB()
+{
+ var i;
+ var data="x";
+ for (i=0 ; i < 20 ; i++)
+ data+=data;
+ return data;
+}
+
+function write_and_check(str, data, len)
+{
+ var written = str.write(data, len);
+ if (written != len) {
+ do_throw("str.write has not written all data!\n" +
+ " Expected: " + len + "\n" +
+ " Actual: " + written + "\n");
+ }
+}
+
+function write_datafile(status, entry)
+{
+ do_check_eq(status, Cr.NS_OK);
+ var os = entry.openOutputStream(0);
+ var data = gen_1MiB();
+
+ // write 2MiB
+ var i;
+ for (i=0 ; i<2 ; i++)
+ write_and_check(os, data, data.length);
+
+ os.close();
+ entry.close();
+
+ // now change max_entry_size so that the existing entry is too big
+ get_pref_service().setIntPref("browser.cache.disk.max_entry_size", 1024);
+
+ // append to entry
+ asyncOpenCacheEntry("http://data/",
+ "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null,
+ append_datafile);
+}
+
+function append_datafile(status, entry)
+{
+ do_check_eq(status, Cr.NS_OK);
+ var os = entry.openOutputStream(entry.dataSize);
+ var data = gen_1MiB();
+
+ // append 1MiB
+ try {
+ write_and_check(os, data, data.length);
+ do_throw();
+ }
+ catch (ex) { }
+
+ // closing the ostream should fail in this case
+ try {
+ os.close();
+ do_throw();
+ }
+ catch (ex) { }
+
+ entry.close();
+
+ do_test_finished();
+}
+
+function run_test() {
+ do_get_profile();
+
+ // clear the cache
+ evict_cache_entries();
+
+ asyncOpenCacheEntry("http://data/",
+ "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null,
+ write_datafile);
+
+ do_test_pending();
+}