3 var testpath = "/bug1054739";
6 let intlPrefs = Services.prefs.getBranch("intl.");
8 let oldAcceptLangPref = intlPrefs.getCharPref("accept_languages");
15 ["az-latn", "az-Latn"],
16 ["sl-nedis", "sl-nedis"],
17 ["zh-hant-hk", "zh-Hant-HK"],
18 ["ZH-HANT-HK", "zh-Hant-HK"],
19 ["en-us-x-priv", "en-US-x-priv"],
20 ["en-us-x-twain", "en-US-x-twain"],
21 ["de, en-US, en", "de,en-US;q=0.7,en;q=0.3"],
22 ["de,en-us,en", "de,en-US;q=0.7,en;q=0.3"],
23 ["en-US, en", "en-US,en;q=0.5"],
24 ["EN-US;q=0.2, EN", "en-US,en;q=0.5"],
25 ["en ;q=0.8, de ", "en,de;q=0.5"],
29 for (let i = 0; i < testData.length; i++) {
30 let acceptLangPref = testData[i][0];
31 let expectedHeader = testData[i][1];
33 intlPrefs.setCharPref("accept_languages", acceptLangPref);
34 let acceptLangHeader =
35 setupChannel(testpath).getRequestHeader("Accept-Language");
36 equal(acceptLangHeader, expectedHeader);
39 intlPrefs.setCharPref("accept_languages", oldAcceptLangPref);
42 function setupChannel(path) {
43 let uri = NetUtil.newURI("http://localhost:4444" + path);
44 let chan = NetUtil.newChannel({
46 loadUsingSystemPrincipal: true,
48 chan.QueryInterface(Ci.nsIHttpChannel);