toolkit/mozapps/update/tests/unit_aus_update/updateManagerXML.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
michael@0 4 */
michael@0 5
michael@0 6 function run_test() {
michael@0 7 setupTestCommon();
michael@0 8
michael@0 9 logTestInfo("testing addition of a successful update to " + FILE_UPDATES_DB +
michael@0 10 " and verification of update properties including the format " +
michael@0 11 "prior to bug 530872");
michael@0 12
michael@0 13 setUpdateChannel("test_channel");
michael@0 14
michael@0 15 var patch, patches, update, updates;
michael@0 16 // XXXrstrong - not specifying a detailsURL will cause a leak due to bug 470244
michael@0 17 // and until bug 470244 is fixed this will not test the value for detailsURL
michael@0 18 // when it isn't specified in the update xml.
michael@0 19 patches = getLocalPatchString("partial", "http://partial/", "SHA256", "cd43",
michael@0 20 "86", "true", STATE_PENDING);
michael@0 21 updates = getLocalUpdateString(patches, "major", "New", "version 4", "4.0",
michael@0 22 "4.0", "20070811053724", "http://details1/",
michael@0 23 "http://billboard1/", "http://license1/",
michael@0 24 "http://service1/", "1238441300314",
michael@0 25 "test status text", "false", "test_channel",
michael@0 26 "true", "true", "true", "345600", "true",
michael@0 27 "test version", "3.0", "3.0",
michael@0 28 "custom1_attr=\"custom1 value\"",
michael@0 29 "custom2_attr=\"custom2 value\"");
michael@0 30
michael@0 31 writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true);
michael@0 32 writeStatusFile(STATE_SUCCEEDED);
michael@0 33
michael@0 34 patches = getLocalPatchString("complete", "http://complete/", "SHA1", "6232",
michael@0 35 "75", "true", STATE_FAILED);
michael@0 36 updates = getLocalUpdateString(patches, "major", "Existing", null, null,
michael@0 37 "3.0", null, "http://details2/", null, null,
michael@0 38 "http://service2/", null,
michael@0 39 getString("patchApplyFailure"), "true",
michael@0 40 "test_channel", "false", null, null, "691200",
michael@0 41 null, "version 3", "3.0", null,
michael@0 42 "custom3_attr=\"custom3 value\"",
michael@0 43 "custom4_attr=\"custom4 value\"");
michael@0 44 writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), false);
michael@0 45
michael@0 46 standardInit();
michael@0 47
michael@0 48 do_check_eq(gUpdateManager.activeUpdate, null);
michael@0 49 do_check_eq(gUpdateManager.updateCount, 2);
michael@0 50
michael@0 51 update = gUpdateManager.getUpdateAt(0).QueryInterface(AUS_Ci.nsIPropertyBag);
michael@0 52 do_check_eq(update.state, STATE_SUCCEEDED);
michael@0 53 do_check_eq(update.type, "major");
michael@0 54 do_check_eq(update.name, "New");
michael@0 55 do_check_eq(update.displayVersion, "version 4");
michael@0 56 do_check_eq(update.appVersion, "4.0");
michael@0 57 do_check_eq(update.platformVersion, "4.0");
michael@0 58 do_check_eq(update.buildID, "20070811053724");
michael@0 59 do_check_eq(update.detailsURL, "http://details1/");
michael@0 60 do_check_eq(update.billboardURL, "http://billboard1/");
michael@0 61 do_check_eq(update.licenseURL, "http://license1/");
michael@0 62 do_check_eq(update.serviceURL, "http://service1/");
michael@0 63 do_check_eq(update.installDate, "1238441300314");
michael@0 64 // statusText is updated
michael@0 65 do_check_eq(update.statusText, getString("installSuccess"));
michael@0 66 do_check_false(update.isCompleteUpdate);
michael@0 67 do_check_eq(update.channel, "test_channel");
michael@0 68 do_check_true(update.showPrompt);
michael@0 69 do_check_true(update.showNeverForVersion);
michael@0 70 do_check_eq(update.promptWaitTime, "345600");
michael@0 71 do_check_eq(update.previousAppVersion, "3.0");
michael@0 72 // Custom attributes
michael@0 73 do_check_eq(update.getProperty("custom1_attr"), "custom1 value");
michael@0 74 do_check_eq(update.getProperty("custom2_attr"), "custom2 value");
michael@0 75
michael@0 76 patch = update.selectedPatch;
michael@0 77 do_check_eq(patch.type, "partial");
michael@0 78 do_check_eq(patch.URL, "http://partial/");
michael@0 79 do_check_eq(patch.hashFunction, "SHA256");
michael@0 80 do_check_eq(patch.hashValue, "cd43");
michael@0 81 do_check_eq(patch.size, "86");
michael@0 82 do_check_true(patch.selected);
michael@0 83 do_check_eq(patch.state, STATE_SUCCEEDED);
michael@0 84
michael@0 85 update = gUpdateManager.getUpdateAt(1).QueryInterface(AUS_Ci.nsIPropertyBag);
michael@0 86 do_check_eq(update.state, STATE_FAILED);
michael@0 87 do_check_eq(update.name, "Existing");
michael@0 88 do_check_eq(update.type, "major");
michael@0 89 do_check_eq(update.displayVersion, "version 3");
michael@0 90 do_check_eq(update.appVersion, "3.0");
michael@0 91 do_check_eq(update.platformVersion, "3.0");
michael@0 92 do_check_eq(update.detailsURL, "http://details2/");
michael@0 93 do_check_eq(update.billboardURL, "http://details2/");
michael@0 94 do_check_eq(update.licenseURL, null);
michael@0 95 do_check_eq(update.serviceURL, "http://service2/");
michael@0 96 do_check_eq(update.installDate, "1238441400314");
michael@0 97 do_check_eq(update.statusText, getString("patchApplyFailure"));
michael@0 98 do_check_eq(update.buildID, "20080811053724");
michael@0 99 do_check_true(update.isCompleteUpdate);
michael@0 100 do_check_eq(update.channel, "test_channel");
michael@0 101 do_check_true(update.showPrompt);
michael@0 102 do_check_true(update.showNeverForVersion);
michael@0 103 do_check_eq(update.promptWaitTime, "691200");
michael@0 104 do_check_eq(update.previousAppVersion, null);
michael@0 105 // Custom attributes
michael@0 106 do_check_eq(update.getProperty("custom3_attr"), "custom3 value");
michael@0 107 do_check_eq(update.getProperty("custom4_attr"), "custom4 value");
michael@0 108
michael@0 109 patch = update.selectedPatch;
michael@0 110 do_check_eq(patch.type, "complete");
michael@0 111 do_check_eq(patch.URL, "http://complete/");
michael@0 112 do_check_eq(patch.hashFunction, "SHA1");
michael@0 113 do_check_eq(patch.hashValue, "6232");
michael@0 114 do_check_eq(patch.size, "75");
michael@0 115 do_check_true(patch.selected);
michael@0 116 do_check_eq(patch.state, STATE_FAILED);
michael@0 117
michael@0 118 removeUpdateDirsAndFiles();
michael@0 119
michael@0 120 // XXXrstrong - not specifying a detailsURL will cause a leak due to bug 470244
michael@0 121 // and until this is fixed this will not test the value for detailsURL when it
michael@0 122 // isn't specified in the update xml.
michael@0 123 patches = getLocalPatchString(null, null, null, null, null, null,
michael@0 124 STATE_PENDING);
michael@0 125 updates = getLocalUpdateString(patches, "major", "New", null, null, "4.0",
michael@0 126 null, "http://details/", "http://billboard/",
michael@0 127 "http://license/", "http://service/",
michael@0 128 "1238441400314", "test status text", null,
michael@0 129 "test_channel", "true", "true", "true", "100",
michael@0 130 "true", "version 4.0", "4.0", "3.0");
michael@0 131
michael@0 132 writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true);
michael@0 133 writeStatusFile(STATE_SUCCEEDED);
michael@0 134
michael@0 135 patches = getLocalPatchString(null, null, null, null, null, null,
michael@0 136 STATE_FAILED);
michael@0 137 updates = getLocalUpdateString(patches, "major", "Existing", "version 3.0",
michael@0 138 "3.0", "3.0", null, "http://details/", null,
michael@0 139 null, "http://service/", null,
michael@0 140 getString("patchApplyFailure"), null,
michael@0 141 "test_channel", "false", null, null, "200",
michael@0 142 null, "version 3", null, null);
michael@0 143 writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), false);
michael@0 144
michael@0 145 reloadUpdateManagerData();
michael@0 146 initUpdateServiceStub();
michael@0 147
michael@0 148 do_check_eq(gUpdateManager.activeUpdate, null);
michael@0 149 do_check_eq(gUpdateManager.updateCount, 2);
michael@0 150
michael@0 151 update = gUpdateManager.getUpdateAt(0);
michael@0 152 do_check_eq(update.state, STATE_SUCCEEDED);
michael@0 153 do_check_eq(update.type, "major");
michael@0 154 do_check_eq(update.name, "New");
michael@0 155 do_check_eq(update.displayVersion, "version 4.0");
michael@0 156 do_check_eq(update.appVersion, "4.0");
michael@0 157 do_check_eq(update.platformVersion, "4.0");
michael@0 158 do_check_eq(update.detailsURL, "http://details/");
michael@0 159 do_check_eq(update.billboardURL, "http://billboard/");
michael@0 160 do_check_eq(update.licenseURL, "http://license/");
michael@0 161 do_check_eq(update.serviceURL, "http://service/");
michael@0 162 do_check_eq(update.installDate, "1238441400314");
michael@0 163 do_check_eq(update.statusText, getString("installSuccess"));
michael@0 164 do_check_eq(update.buildID, "20080811053724");
michael@0 165 do_check_true(update.isCompleteUpdate);
michael@0 166 do_check_eq(update.channel, "test_channel");
michael@0 167 do_check_true(update.showPrompt);
michael@0 168 do_check_true(update.showNeverForVersion);
michael@0 169 do_check_eq(update.promptWaitTime, "100");
michael@0 170 do_check_eq(update.previousAppVersion, "3.0");
michael@0 171
michael@0 172 patch = update.selectedPatch;
michael@0 173 do_check_eq(patch.type, "complete");
michael@0 174 do_check_eq(patch.URL, URL_HOST + "/" + FILE_SIMPLE_MAR);
michael@0 175 do_check_eq(patch.hashFunction, "MD5");
michael@0 176 do_check_eq(patch.hashValue, MD5_HASH_SIMPLE_MAR);
michael@0 177 do_check_eq(patch.size, SIZE_SIMPLE_MAR);
michael@0 178 do_check_true(patch.selected);
michael@0 179 do_check_eq(patch.state, STATE_SUCCEEDED);
michael@0 180
michael@0 181 update = gUpdateManager.getUpdateAt(1);
michael@0 182 do_check_eq(update.state, STATE_FAILED);
michael@0 183 do_check_eq(update.name, "Existing");
michael@0 184 do_check_eq(update.type, "major");
michael@0 185 do_check_eq(update.displayVersion, "version 3.0");
michael@0 186 do_check_eq(update.appVersion, "3.0");
michael@0 187 do_check_eq(update.platformVersion, "3.0");
michael@0 188 do_check_eq(update.detailsURL, "http://details/");
michael@0 189 do_check_eq(update.billboardURL, null);
michael@0 190 do_check_eq(update.licenseURL, null);
michael@0 191 do_check_eq(update.serviceURL, "http://service/");
michael@0 192 do_check_eq(update.installDate, "1238441400314");
michael@0 193 do_check_eq(update.statusText, getString("patchApplyFailure"));
michael@0 194 do_check_eq(update.buildID, "20080811053724");
michael@0 195 do_check_true(update.isCompleteUpdate);
michael@0 196 do_check_eq(update.channel, "test_channel");
michael@0 197 do_check_false(update.showPrompt);
michael@0 198 do_check_false(update.showNeverForVersion);
michael@0 199 do_check_eq(update.promptWaitTime, "200");
michael@0 200 do_check_eq(update.previousAppVersion, null);
michael@0 201
michael@0 202 patch = update.selectedPatch;
michael@0 203 do_check_eq(patch.type, "complete");
michael@0 204 do_check_eq(patch.URL, URL_HOST + "/" + FILE_SIMPLE_MAR);
michael@0 205 do_check_eq(patch.hashFunction, "MD5");
michael@0 206 do_check_eq(patch.hashValue, MD5_HASH_SIMPLE_MAR);
michael@0 207 do_check_eq(patch.size, SIZE_SIMPLE_MAR);
michael@0 208 do_check_true(patch.selected);
michael@0 209 do_check_eq(patch.state, STATE_FAILED);
michael@0 210
michael@0 211 doTestFinish();
michael@0 212 }

mercurial