browser/experiments/test/xpcshell/test_upgrade.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* Any copyright is dedicated to the Public Domain.
michael@0 2 * http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0 3
michael@0 4 "use strict";
michael@0 5 Cu.import("resource:///modules/experiments/Experiments.jsm");
michael@0 6
michael@0 7 const SEC_IN_ONE_DAY = 24 * 60 * 60;
michael@0 8 const MS_IN_ONE_DAY = SEC_IN_ONE_DAY * 1000;
michael@0 9
michael@0 10 let cacheData = {
michael@0 11 _enabled: true,
michael@0 12 _manifestData: {
michael@0 13 id: "foobartestid",
michael@0 14 xpiURL: "http://example.com/foo.xpi",
michael@0 15 xpiHash: "sha256:abcde",
michael@0 16 startTime: 0,
michael@0 17 endTime: 2000000000,
michael@0 18 maxActiveSeconds: 40000000,
michael@0 19 appName: "TestApp",
michael@0 20 channel: "test-foo",
michael@0 21 },
michael@0 22 _needsUpdate: false,
michael@0 23 _randomValue: 0.5,
michael@0 24 _failedStart: false,
michael@0 25 _name: "Foo",
michael@0 26 _description: "Foobar",
michael@0 27 _homepageURL: "",
michael@0 28 _addonId: "foo@test",
michael@0 29 _startDate: 0,
michael@0 30 _endDate: 2000000000,
michael@0 31 _branch: null
michael@0 32 };
michael@0 33
michael@0 34 add_task(function* test_valid() {
michael@0 35 let e = new Experiments.ExperimentEntry();
michael@0 36 Assert.ok(e.initFromCacheData(cacheData));
michael@0 37 Assert.ok(e.enabled);
michael@0 38 });
michael@0 39
michael@0 40 add_task(function* test_upgrade() {
michael@0 41 let e = new Experiments.ExperimentEntry();
michael@0 42 delete cacheData._branch;
michael@0 43 Assert.ok(e.initFromCacheData(cacheData));
michael@0 44 Assert.ok(e.enabled);
michael@0 45 });
michael@0 46
michael@0 47 add_task(function* test_missing() {
michael@0 48 let e = new Experiments.ExperimentEntry();
michael@0 49 delete cacheData._name;
michael@0 50 Assert.ok(!e.initFromCacheData(cacheData));
michael@0 51 });
michael@0 52
michael@0 53 function run_test() {
michael@0 54 run_next_test();
michael@0 55 }

mercurial