Bug 821484 - ASSERTION: mDone shouldn't have been set to true already!: '!mDone', file dom/base/DOMRequest.cpp, line 113. r=sicking
authorGregor Wagner <anygregor@gmail.com>
Thu, 13 Dec 2012 16:46:13 -0800
changeset 116018 04b23376b9c323d5480b0bae17d84741e4065df4
parent 116017 c6568365b0ec2d55aaab12a906af60a4bb2f0e4c
child 116019 9585e38ed39d87971ff1322259c710f6610510a2
push id24034
push useremorley@mozilla.com
push dateFri, 14 Dec 2012 15:28:57 +0000
treeherdermozilla-central@50d8f411d305 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssicking
bugs821484
milestone20.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 821484 - ASSERTION: mDone shouldn't have been set to true already!: '!mDone', file dom/base/DOMRequest.cpp, line 113. r=sicking
dom/settings/SettingsManager.js
dom/settings/tests/test_settings_basics.html
--- a/dom/settings/SettingsManager.js
+++ b/dom/settings/SettingsManager.js
@@ -49,17 +49,20 @@ SettingsLock.prototype = {
         case "clear":
           let req = store.clear();
           req.onsuccess = function() { this._open = true;
                                        Services.DOMRequest.fireSuccess(request, 0);
                                        this._open = false; }.bind(lock);
           req.onerror = function() { Services.DOMRequest.fireError(request, 0) };
           break;
         case "set":
-          for (let key in info.settings) {
+          let keys = Object.getOwnPropertyNames(info.settings);
+          for (let i = 0; i < keys.length; i++) {
+            let key = keys[i];
+            let last = i === keys.length - 1;
             debug("key: " + key + ", val: " + JSON.stringify(info.settings[key]) + ", type: " + typeof(info.settings[key]));
 
             let checkKeyRequest = store.get(key);
             checkKeyRequest.onsuccess = function (event) {
               if (!event.target.result) {
                 debug("MOZSETTINGS-SET-WARNING: " + key + " is not in the database. Please add it to build/settings.js\n");
               }
             }
@@ -67,25 +70,29 @@ SettingsLock.prototype = {
             if(typeof(info.settings[key]) != 'object') {
               req = store.put({settingName: key, settingValue: info.settings[key]});
             } else {
               //Workaround for cloning issues
               let obj = JSON.parse(JSON.stringify(info.settings[key]));
               req = store.put({settingName: key, settingValue: obj});
             }
 
-            req.onsuccess = function() { 
-              lock._open = true;
-              Services.DOMRequest.fireSuccess(request, 0);
+            req.onsuccess = function() {
+              if (last && !request.error) {
+                lock._open = true;
+                Services.DOMRequest.fireSuccess(request, 0);
+                lock._open = false;
+              }
               cpmm.sendAsyncMessage("Settings:Changed", { key: key, value: info.settings[key] });
-              lock._open = false;
             };
 
             req.onerror = function() {
-              Services.DOMRequest.fireError(request, 0)
+              if (!request.error) {
+                Services.DOMRequest.fireError(request, req.error.name)
+              }
             };
           }
           break;
         case "get":
           req = (info.name === "*") ? store.mozGetAll()
                                     : store.mozGetAll(info.name);
 
           req.onsuccess = function(event) {
--- a/dom/settings/tests/test_settings_basics.html
+++ b/dom/settings/tests/test_settings_basics.html
@@ -38,16 +38,23 @@ function onFailure() {
 var wifi  = {"net3g.apn": "internet.mnc012.mcc345.gprs"};
 var wifi2 = {"net3g.apn": "internet.mnc012.mcc345.test"};
 var wifiEnabled = {"wifi.enabled": true};
 var wifiDisabled = {"wifi.enabled": false};
 var screenBright = {"screen.brightness": 0.7};
 var wifiNetworks0 = { "wifi.networks[0]": { ssid: "myfreenetwork", mac: "01:23:45:67:89:ab", passwd: "secret"}};
 var wifiNetworks1 = { "wifi.networks[1]": { ssid: "myfreenetwork2", mac: "01:23:45:67:89:ab", passwd: "secret2"}};
 
+var combination = {
+  "wifi.enabled": false,
+  "screen.brightness": 0.7,
+  "wifi.networks[0]": { ssid: "myfreenetwork", mac: "01:23:45:67:89:ab", passwd: "secret" },
+  "test.test": true
+}
+
 function equals(o1, o2) {
   var k1 = Object.keys(o1).sort();
   var k2 = Object.keys(o2).sort();
   if (k1.length != k2.length) return false;
   return k1.zip(k2, function(keyPair) {
     if(typeof o1[keyPair[0]] == typeof o2[keyPair[1]] == "object"){
       return equals(o1[keyPair[0]], o2[keyPair[1]])
     } else {
@@ -606,16 +613,46 @@ var steps = [
     var lock = mozSettings.createLock();
     req = lock.clear();
     req.onsuccess = function () {
       ok(true, "Deleted the database");
       next();
     };
     req.onerror = onFailure;
   },
+  function() {
+    ok(true, "Set with multiple arguments");
+    var lock = mozSettings.createLock();
+    req = lock.set(combination);
+    req.onsuccess = function () {
+      ok(true, "Set Done");
+      next();
+    };
+    req.onerror = onFailure;
+  },
+  function() {
+    ok(true, "request argument from multiple set");
+    var lock = mozSettings.createLock();
+    req = lock.get("screen.brightness");
+    req.onsuccess = function () {
+      check(req.result["screen.brightness"], 0.7, "get done");
+      next();
+    }
+    req.onerror = onFailure;
+  },
+  function() {
+    ok(true, "Clear DB");
+    var lock = mozSettings.createLock();
+    req = lock.clear();
+    req.onsuccess = function () {
+      ok(true, "Deleted the database");
+      next();
+    };
+    req.onerror = onFailure;
+  },
   function () {
     ok(true, "all done!\n");
     SimpleTest.finish();
   }
 ];
 
 function next() {
   ok(true, "Begin!");