author | Dave Townsend <dtownsend@oxymoronical.com> |
Tue, 08 Mar 2011 09:57:59 -0800 | |
changeset 63357 | 19021b7524f2cbacfa15b131a633ca96d0b04d2a |
parent 63356 | 53f4bee0bc1192c9a0d95fe72ba7f7675a28f47b |
child 63358 | acb121c0e3407951ee476ed621166d1b13f09e0b |
push id | 1 |
push user | root |
push date | Tue, 26 Apr 2011 22:38:44 +0000 |
treeherder | mozilla-beta@bfdb6e623a36 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | robstrong, tests |
bugs | 611178 |
milestone | 2.0b13pre |
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
|
toolkit/mozapps/extensions/test/xpcshell/test_install.js | file | annotate | diff | comparison | revisions |
--- a/toolkit/mozapps/extensions/test/xpcshell/test_install.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_install.js @@ -1,17 +1,18 @@ /* Any copyright is dedicated to the Public Domain. * http://creativecommons.org/publicdomain/zero/1.0/ */ // This verifies that add-ons can be installed from XPI files -// The maximum allowable time since install. If an add-on claims to have been -// installed longer ago than this the the test will fail. -const MAX_INSTALL_TIME = 10000; +// Maximum error in file modification times. Some file systems don't store +// modification times exactly. As long as we are closer than this then it +// still passes. +const MAX_TIME_DIFFERENCE = 3000; Components.utils.import("resource://gre/modules/Services.jsm"); Components.utils.import("resource://gre/modules/NetUtil.jsm"); // install.rdf size, icon.png, icon64.png size const ADDON1_SIZE = 705 + 16 + 16; do_load_httpd_js(); @@ -133,16 +134,22 @@ function check_test_1() { zipReader.close(); } } else { let iconFile = uri.QueryInterface(AM_Ci.nsIFileURL).file; do_check_true(iconFile.exists()); } + // Make the pending install have a sensible date + let updateDate = Date.now(); + let extURI = pendingAddons[0].getResourceURI(""); + let ext = extURI.QueryInterface(AM_Ci.nsIFileURL).file; + setExtensionModifiedTime(ext, updateDate); + // The pending add-on cannot be disabled or enabled. do_check_false(hasFlag(pendingAddons[0].permissions, AddonManager.PERM_CAN_ENABLE)); do_check_false(hasFlag(pendingAddons[0].permissions, AddonManager.PERM_CAN_DISABLE)); restartManager(); AddonManager.getAllInstalls(function(activeInstalls) { do_check_eq(activeInstalls, 0); @@ -154,24 +161,23 @@ function check_test_1() { do_check_eq(a1.name, "Test 1"); do_check_true(isExtensionInAddonsList(profileDir, a1.id)); do_check_true(do_get_addon("test_install1").exists()); do_check_in_crash_annotation(a1.id, a1.version); do_check_eq(a1.size, ADDON1_SIZE); do_check_eq(a1.sourceURI.spec, Services.io.newFileURI(do_get_addon("test_install1")).spec); - // Should have been installed sometime in the last two second. - let difference = Date.now() - a1.installDate.getTime(); - if (difference > MAX_INSTALL_TIME) - do_throw("Add-on was installed " + difference + "ms ago"); - if (difference < 0) - do_throw("Add-on was installed " + difference + "ms in the future"); + let difference = a1.installDate.getTime() - updateDate; + if (Math.abs(difference) > MAX_TIME_DIFFERENCE) + do_throw("Add-on install time was out by " + difference + "ms"); - do_check_eq(a1.installDate.getTime(), a1.updateDate.getTime()); + difference = a1.updateDate.getTime() - updateDate; + if (Math.abs(difference) > MAX_TIME_DIFFERENCE) + do_throw("Add-on update time was out by " + difference + "ms"); do_check_true(a1.hasResource("install.rdf")); do_check_false(a1.hasResource("foo.bar")); let uri = do_get_addon_root_uri(profileDir, "addon1@tests.mozilla.org"); do_check_eq(a1.getResourceURI("install.rdf").spec, uri + "install.rdf"); do_check_eq(a1.iconURL, uri + "icon.png"); do_check_eq(a1.icon64URL, uri + "icon64.png"); @@ -244,17 +250,23 @@ function run_test_3(install) { ] }, [ "onInstallStarted", "onInstallEnded", ], check_test_3); install.install(); } -function check_test_3() { +function check_test_3(aInstall) { + // Make the pending install have a sensible date + let updateDate = Date.now(); + let extURI = aInstall.addon.getResourceURI(""); + let ext = extURI.QueryInterface(AM_Ci.nsIFileURL).file; + setExtensionModifiedTime(ext, updateDate); + ensure_test_completed(); AddonManager.getAddonByID("addon2@tests.mozilla.org", function(olda2) { do_check_eq(olda2, null); restartManager(); AddonManager.getAllInstalls(function(installs) { do_check_eq(installs, 0); @@ -264,24 +276,24 @@ function check_test_3() { do_check_eq(a2.version, "2.0"); do_check_eq(a2.name, "Real Test 2"); do_check_true(isExtensionInAddonsList(profileDir, a2.id)); do_check_true(do_get_addon("test_install2_1").exists()); do_check_in_crash_annotation(a2.id, a2.version); do_check_eq(a2.sourceURI.spec, "http://localhost:4444/addons/test_install2_1.xpi"); - // Should have been installed sometime in the last two second. - let difference = Date.now() - a2.installDate.getTime(); - if (difference > MAX_INSTALL_TIME) - do_throw("Add-on was installed " + difference + "ms ago"); - if (difference < 0) - do_throw("Add-on was installed " + difference + "ms in the future"); + let difference = a2.installDate.getTime() - updateDate; + if (Math.abs(difference) > MAX_TIME_DIFFERENCE) + do_throw("Add-on install time was out by " + difference + "ms"); - do_check_eq(a2.installDate.getTime(), a2.updateDate.getTime()); + difference = a2.updateDate.getTime() - updateDate; + if (Math.abs(difference) > MAX_TIME_DIFFERENCE) + do_throw("Add-on update time was out by " + difference + "ms"); + gInstallDate = a2.installDate.getTime(); run_test_4(); }); }); }); }