Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
4 /**
5 * Tests if the preferences and localization objects work correctly.
6 */
8 function test() {
9 initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => {
10 info("Starting test... ");
12 ok(aMonitor.panelWin.L10N,
13 "Should have a localization object available on the panel window.");
14 ok(aMonitor.panelWin.Prefs,
15 "Should have a preferences object available on the panel window.");
17 function testL10N() {
18 let { L10N } = aMonitor.panelWin;
20 ok(L10N.stringBundle,
21 "The localization object should have a string bundle available.");
23 let bundleName = "chrome://browser/locale/devtools/netmonitor.properties";
24 let stringBundle = Services.strings.createBundle(bundleName);
26 is(L10N.getStr("netmonitor.label"),
27 stringBundle.GetStringFromName("netmonitor.label"),
28 "The getStr() method didn't return the expected string.");
30 is(L10N.getFormatStr("networkMenu.totalMS", "foo"),
31 stringBundle.formatStringFromName("networkMenu.totalMS", ["foo"], 1),
32 "The getFormatStr() method didn't return the expected string.");
33 }
35 function testPrefs() {
36 let { Prefs } = aMonitor.panelWin;
38 is(Prefs.root, "devtools.netmonitor",
39 "The preferences object should have a correct root path.");
41 is(Prefs.networkDetailsWidth,
42 Services.prefs.getIntPref("devtools.netmonitor.panes-network-details-width"),
43 "Getting a pref should work correctly.");
45 let previousValue = Prefs.networkDetailsWidth;
46 let bogusValue = ~~(Math.random() * 100);
47 Prefs.networkDetailsWidth = bogusValue;
48 is(Prefs.networkDetailsWidth,
49 Services.prefs.getIntPref("devtools.netmonitor.panes-network-details-width"),
50 "Getting a pref after it has been modified should work correctly.");
51 is(Prefs.networkDetailsWidth, bogusValue,
52 "The pref wasn't updated correctly in the preferences object.");
54 Prefs.networkDetailsWidth = previousValue;
55 is(Prefs.networkDetailsWidth,
56 Services.prefs.getIntPref("devtools.netmonitor.panes-network-details-width"),
57 "Getting a pref after it has been modified again should work correctly.");
58 is(Prefs.networkDetailsWidth, previousValue,
59 "The pref wasn't updated correctly again in the preferences object.");
60 }
62 testL10N();
63 testPrefs();
65 teardown(aMonitor).then(finish);
66 });
67 }