toolkit/content/tests/chrome/test_preferences.xul

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.

     1 <?xml version="1.0"?>
     2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
     3 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
     5 <window title="Preferences Window Tests"
     6         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
     7         onload="RunTest();">
     9   <script type="application/javascript"
    10           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
    12   <script type="application/javascript">
    13   <![CDATA[
    14     if (navigator.platform.startsWith("Mac")) {
    15       SimpleTest.expectAssertions(4);
    16     } else {
    17       SimpleTest.expectAssertions(0,1);
    18     }
    19     SimpleTest.waitForExplicitFinish();
    21     const kPref = Components.classes["@mozilla.org/preferences-service;1"]
    22                             .getService(Components.interfaces.nsIPrefBranch);
    24     // preference values, set 1
    25     const kPrefValueSet1 =
    26     {
    27         int:          23,
    28         bool:         true,
    29         string:       "rheeet!",
    30         wstring_data: "日本語",
    31         unichar_data: "äöüßÄÖÜ",
    32         file_data:    "/",
    34         wstring: Components.classes["@mozilla.org/pref-localizedstring;1"]
    35                            .createInstance(Components.interfaces.nsIPrefLocalizedString),
    36         unichar: Components.classes["@mozilla.org/supports-string;1"]
    37                            .createInstance(Components.interfaces.nsISupportsString),
    38         file:    Components.classes["@mozilla.org/file/local;1"]
    39                            .createInstance(Components.interfaces.nsILocalFile)
    40     };
    41     kPrefValueSet1.wstring.data = kPrefValueSet1.wstring_data;
    42     kPrefValueSet1.unichar.data = kPrefValueSet1.unichar_data;
    43     SafeFileInit(kPrefValueSet1.file, kPrefValueSet1.file_data);
    45     // preference values, set 2
    46     const kPrefValueSet2 =
    47     {
    48         int:          42,
    49         bool:         false,
    50         string:       "Mozilla",
    51         wstring_data: "헤드라인A",
    52         unichar_data: "áôùšŽ",
    53         file_data:    "/home",
    55         wstring: Components.classes["@mozilla.org/pref-localizedstring;1"]
    56                            .createInstance(Components.interfaces.nsIPrefLocalizedString),
    57         unichar: Components.classes["@mozilla.org/supports-string;1"]
    58                            .createInstance(Components.interfaces.nsISupportsString),
    59         file:    Components.classes["@mozilla.org/file/local;1"]
    60                            .createInstance(Components.interfaces.nsILocalFile)
    61     };
    62     kPrefValueSet2.wstring.data = kPrefValueSet2.wstring_data;
    63     kPrefValueSet2.unichar.data = kPrefValueSet2.unichar_data;
    64     SafeFileInit(kPrefValueSet2.file, kPrefValueSet2.file_data);
    67     function SafeFileInit(aFile, aPath)
    68     {
    69       // set file path without dying for exceptions
    70       try
    71       {
    72         aFile.initWithPath(aPath);
    73       }
    74       catch (ignored) {}
    75     }
    77     function CreateEmptyPrefValueSet()
    78     {
    79       var result =
    80       {
    81         int:          undefined,
    82         bool:         undefined,
    83         string:       undefined,
    84         wstring_data: undefined,
    85         unichar_data: undefined,
    86         file_data:    undefined,
    87         wstring:      undefined,
    88         unichar:      undefined,
    89         file:         undefined
    90       };
    91       return result;
    92     }
    94     function WritePrefsToSystem(aPrefValueSet)
    95     {
    96       // write preference data via XPCOM
    97       kPref.setIntPref ("tests.static_preference_int",    aPrefValueSet.int);
    98       kPref.setBoolPref("tests.static_preference_bool",   aPrefValueSet.bool);
    99       kPref.setCharPref("tests.static_preference_string", aPrefValueSet.string);
   100       kPref.setComplexValue("tests.static_preference_wstring",
   101                             Components.interfaces.nsIPrefLocalizedString,
   102                             aPrefValueSet.wstring);
   103       kPref.setComplexValue("tests.static_preference_unichar",
   104                             Components.interfaces.nsISupportsString,
   105                             aPrefValueSet.unichar);
   106       kPref.setComplexValue("tests.static_preference_file",
   107                             Components.interfaces.nsILocalFile,
   108                             aPrefValueSet.file);
   109     }
   111     function ReadPrefsFromSystem()
   112     {
   113       // read preference data via XPCOM
   114       var result = CreateEmptyPrefValueSet();
   115       try {result.int    = kPref.getIntPref ("tests.static_preference_int")   } catch (ignored) {};
   116       try {result.bool   = kPref.getBoolPref("tests.static_preference_bool")  } catch (ignored) {};
   117       try {result.string = kPref.getCharPref("tests.static_preference_string")} catch (ignored) {};
   118       try
   119       {
   120         result.wstring = kPref.getComplexValue("tests.static_preference_wstring",
   121                                                Components.interfaces.nsIPrefLocalizedString);
   122         result.wstring_data = result.wstring.data;
   123       }
   124       catch (ignored) {};
   125       try
   126       {
   127         result.unichar = kPref.getComplexValue("tests.static_preference_unichar",
   128                                                Components.interfaces.nsISupportsString);
   129         result.unichar_data = result.unichar.data;
   130       }
   131       catch (ignored) {};
   132       try
   133       {
   134         result.file = kPref.getComplexValue("tests.static_preference_file",
   135                                             Components.interfaces.nsILocalFile);
   136         result.file_data    = result.file.data;
   137       }
   138       catch (ignored) {};
   139       return result;
   140     }
   142     function GetXULElement(aPrefWindow, aID)
   143     {
   144       return aPrefWindow.document.getElementById(aID);
   145     }
   147     function WritePrefsToPreferences(aPrefWindow, aPrefValueSet)
   148     {
   149       // write preference data into <preference>s
   150       GetXULElement(aPrefWindow, "tests.static_preference_int"    ).value = aPrefValueSet.int;
   151       GetXULElement(aPrefWindow, "tests.static_preference_bool"   ).value = aPrefValueSet.bool;
   152       GetXULElement(aPrefWindow, "tests.static_preference_string" ).value = aPrefValueSet.string;
   153       GetXULElement(aPrefWindow, "tests.static_preference_wstring").value = aPrefValueSet.wstring_data;
   154       GetXULElement(aPrefWindow, "tests.static_preference_unichar").value = aPrefValueSet.unichar_data;
   155       GetXULElement(aPrefWindow, "tests.static_preference_file"   ).value = aPrefValueSet.file_data;
   156     }
   158     function ReadPrefsFromPreferences(aPrefWindow)
   159     {
   160       // read preference data from <preference>s
   161       var result =
   162       {
   163         int:          GetXULElement(aPrefWindow, "tests.static_preference_int"    ).value,
   164         bool:         GetXULElement(aPrefWindow, "tests.static_preference_bool"   ).value,
   165         string:       GetXULElement(aPrefWindow, "tests.static_preference_string" ).value,
   166         wstring_data: GetXULElement(aPrefWindow, "tests.static_preference_wstring").value,
   167         unichar_data: GetXULElement(aPrefWindow, "tests.static_preference_unichar").value,
   168         file_data:    GetXULElement(aPrefWindow, "tests.static_preference_file"   ).value,
   169         wstring: Components.classes["@mozilla.org/pref-localizedstring;1"]
   170                            .createInstance(Components.interfaces.nsIPrefLocalizedString),
   171         unichar: Components.classes["@mozilla.org/supports-string;1"]
   172                            .createInstance(Components.interfaces.nsISupportsString),
   173         file:    Components.classes["@mozilla.org/file/local;1"]
   174                            .createInstance(Components.interfaces.nsILocalFile)
   175       }
   176       result.wstring.data = result.wstring_data;
   177       result.unichar.data = result.unichar_data;
   178       SafeFileInit(result.file, result.file_data);
   179       return result;
   180     }
   182     function WritePrefsToUI(aPrefWindow, aPrefValueSet)
   183     {
   184       // write preference data into UI elements
   185       GetXULElement(aPrefWindow, "static_element_int"    ).value   = aPrefValueSet.int;
   186       GetXULElement(aPrefWindow, "static_element_bool"   ).checked = aPrefValueSet.bool;
   187       GetXULElement(aPrefWindow, "static_element_string" ).value   = aPrefValueSet.string;
   188       GetXULElement(aPrefWindow, "static_element_wstring").value   = aPrefValueSet.wstring_data;
   189       GetXULElement(aPrefWindow, "static_element_unichar").value   = aPrefValueSet.unichar_data;
   190       GetXULElement(aPrefWindow, "static_element_file"   ).value   = aPrefValueSet.file_data;
   191     }
   193     function ReadPrefsFromUI(aPrefWindow)
   194     {
   195       // read preference data from <preference>s
   196       var result =
   197       {
   198         int:          GetXULElement(aPrefWindow, "static_element_int"    ).value,
   199         bool:         GetXULElement(aPrefWindow, "static_element_bool"   ).checked,
   200         string:       GetXULElement(aPrefWindow, "static_element_string" ).value,
   201         wstring_data: GetXULElement(aPrefWindow, "static_element_wstring").value,
   202         unichar_data: GetXULElement(aPrefWindow, "static_element_unichar").value,
   203         file_data:    GetXULElement(aPrefWindow, "static_element_file"   ).value,
   204         wstring: Components.classes["@mozilla.org/pref-localizedstring;1"]
   205                            .createInstance(Components.interfaces.nsIPrefLocalizedString),
   206         unichar: Components.classes["@mozilla.org/supports-string;1"]
   207                            .createInstance(Components.interfaces.nsISupportsString),
   208         file:    Components.classes["@mozilla.org/file/local;1"]
   209                            .createInstance(Components.interfaces.nsILocalFile)
   210       }
   211       result.wstring.data = result.wstring_data;
   212       result.unichar.data = result.unichar_data;
   213       SafeFileInit(result.file, result.file_data);
   214       return result;
   215     }
   218     function RunInstantPrefTest(aPrefWindow)
   219     {
   220       // remark: there's currently no UI element binding for files
   222       // were all <preferences> correctly initialized?
   223       var expected = kPrefValueSet1;
   224       var found    = ReadPrefsFromPreferences(aPrefWindow);
   225       ok(found.int          === expected.int,          "instant pref init int"    );
   226       ok(found.bool         === expected.bool,         "instant pref init bool"   );
   227       ok(found.string       === expected.string,       "instant pref init string" );
   228       ok(found.wstring_data === expected.wstring_data, "instant pref init wstring");
   229       ok(found.unichar_data === expected.unichar_data, "instant pref init unichar");
   230       todo(found.file_data  === expected.file_data,    "instant pref init file"   );
   232       // were all elements correctly initialized? (loose check)
   233       found = ReadPrefsFromUI(aPrefWindow);
   234       ok(found.int          == expected.int,          "instant element init int"    );
   235       ok(found.bool         == expected.bool,         "instant element init bool"   );
   236       ok(found.string       == expected.string,       "instant element init string" );
   237       ok(found.wstring_data == expected.wstring_data, "instant element init wstring");
   238       ok(found.unichar_data == expected.unichar_data, "instant element init unichar");
   239       todo(found.file_data  == expected.file_data,    "instant element init file"   );
   241       // do some changes in the UI
   242       expected = kPrefValueSet2;
   243       WritePrefsToUI(aPrefWindow, expected);
   245       // UI changes should get passed to the <preference>s,
   246       // but currently they aren't if the changes are made programmatically
   247       // (the handlers preference.change/prefpane.input and prefpane.change
   248       //  are called for manual changes, though).
   249       found = ReadPrefsFromPreferences(aPrefWindow);
   250       todo(found.int          === expected.int,          "instant change pref int"    );
   251       todo(found.bool         === expected.bool,         "instant change pref bool"   );
   252       todo(found.string       === expected.string,       "instant change pref string" );
   253       todo(found.wstring_data === expected.wstring_data, "instant change pref wstring");
   254       todo(found.unichar_data === expected.unichar_data, "instant change pref unichar");
   255       todo(found.file_data    === expected.file_data,    "instant change pref file"   );
   257       // and these changes should get passed to the system instantly
   258       // (which obviously can't pass with the above failing)
   259       found = ReadPrefsFromSystem();
   260       todo(found.int          === expected.int,          "instant change element int"    );
   261       todo(found.bool         === expected.bool,         "instant change element bool"   );
   262       todo(found.string       === expected.string,       "instant change element string" );
   263       todo(found.wstring_data === expected.wstring_data, "instant change element wstring");
   264       todo(found.unichar_data === expected.unichar_data, "instant change element unichar");
   265       todo(found.file_data    === expected.file_data,    "instant change element file"   );
   267       // try resetting the prefs to default values (which should be empty here)
   268       GetXULElement(aPrefWindow, "tests.static_preference_int"    ).reset();
   269       GetXULElement(aPrefWindow, "tests.static_preference_bool"   ).reset();
   270       GetXULElement(aPrefWindow, "tests.static_preference_string" ).reset();
   271       GetXULElement(aPrefWindow, "tests.static_preference_wstring").reset();
   272       GetXULElement(aPrefWindow, "tests.static_preference_unichar").reset();
   273       GetXULElement(aPrefWindow, "tests.static_preference_file"   ).reset();
   275       // check system
   276       expected = CreateEmptyPrefValueSet();
   277       found    = ReadPrefsFromSystem();
   278       ok(found.int          === expected.int,          "instant reset system int"    );
   279       ok(found.bool         === expected.bool,         "instant reset system bool"   );
   280       ok(found.string       === expected.string,       "instant reset system string" );
   281       ok(found.wstring_data === expected.wstring_data, "instant reset system wstring");
   282       ok(found.unichar_data === expected.unichar_data, "instant reset system unichar");
   283       ok(found.file_data    === expected.file_data,    "instant reset system file"   );
   285       // check UI
   286       expected =
   287       {
   288         // alas, we don't have XUL elements with typeof(value) == int :(
   289         // int:         0,
   290         int:          "",
   291         bool:         false,
   292         string:       "",
   293         wstring_data: "",
   294         unichar_data: "",
   295         file_data:    "",
   296         wstring:      {},
   297         unichar:      {},
   298         file:         {}
   299       };
   300       found = ReadPrefsFromUI(aPrefWindow);
   301       ok(found.int          === expected.int,          "instant reset element int"    );
   302       ok(found.bool         === expected.bool,         "instant reset element bool"   );
   303       ok(found.string       === expected.string,       "instant reset element string" );
   304       ok(found.wstring_data === expected.wstring_data, "instant reset element wstring");
   305       ok(found.unichar_data === expected.unichar_data, "instant reset element unichar");
   306 //      ok(found.file_data    === expected.file_data,    "instant reset element file"   );
   308       // check hasUserValue
   309       ok(GetXULElement(aPrefWindow, "tests.static_preference_int"    ).hasUserValue === false, "instant reset hasUserValue int"    );
   310       ok(GetXULElement(aPrefWindow, "tests.static_preference_bool"   ).hasUserValue === false, "instant reset hasUserValue bool"   );
   311       ok(GetXULElement(aPrefWindow, "tests.static_preference_string" ).hasUserValue === false, "instant reset hasUserValue string" );
   312       ok(GetXULElement(aPrefWindow, "tests.static_preference_wstring").hasUserValue === false, "instant reset hasUserValue wstring");
   313       ok(GetXULElement(aPrefWindow, "tests.static_preference_unichar").hasUserValue === false, "instant reset hasUserValue unichar");
   314       ok(GetXULElement(aPrefWindow, "tests.static_preference_file"   ).hasUserValue === false, "instant reset hasUserValue file"   );
   316       // done with instant apply checks
   317     }
   319     function RunNonInstantPrefTestGeneral(aPrefWindow)
   320     {
   321       // Non-instant apply tests are harder: not only do we need to check that
   322       // fiddling with the values does *not* change the system settings, but
   323       // also that they *are* (not) set after closing (cancelling) the dialog...
   325       // remark: there's currently no UI element binding for files
   327       // were all <preferences> correctly initialized?
   328       var expected = kPrefValueSet1;
   329       var found    = ReadPrefsFromPreferences(aPrefWindow);
   330       ok(found.int          === expected.int,          "non-instant pref init int"    );
   331       ok(found.bool         === expected.bool,         "non-instant pref init bool"   );
   332       ok(found.string       === expected.string,       "non-instant pref init string" );
   333       ok(found.wstring_data === expected.wstring_data, "non-instant pref init wstring");
   334       ok(found.unichar_data === expected.unichar_data, "non-instant pref init unichar");
   335       todo(found.file_data  === expected.file_data,    "non-instant pref init file"   );
   337       // were all elements correctly initialized? (loose check)
   338       found = ReadPrefsFromUI(aPrefWindow);
   339       ok(found.int          == expected.int,          "non-instant element init int"    );
   340       ok(found.bool         == expected.bool,         "non-instant element init bool"   );
   341       ok(found.string       == expected.string,       "non-instant element init string" );
   342       ok(found.wstring_data == expected.wstring_data, "non-instant element init wstring");
   343       ok(found.unichar_data == expected.unichar_data, "non-instant element init unichar");
   344       todo(found.file_data  == expected.file_data,    "non-instant element init file"   );
   346       // do some changes in the UI
   347       expected = kPrefValueSet2;
   348       WritePrefsToUI(aPrefWindow, expected);
   350       // UI changes should get passed to the <preference>s,
   351       // but currently they aren't if the changes are made programmatically
   352       // (the handlers preference.change/prefpane.input and prefpane.change
   353       //  are called for manual changes, though).
   354       found = ReadPrefsFromPreferences(aPrefWindow);
   355       todo(found.int          === expected.int,          "non-instant change pref int"    );
   356       todo(found.bool         === expected.bool,         "non-instant change pref bool"   );
   357       todo(found.string       === expected.string,       "non-instant change pref string" );
   358       todo(found.wstring_data === expected.wstring_data, "non-instant change pref wstring");
   359       todo(found.unichar_data === expected.unichar_data, "non-instant change pref unichar");
   360       todo(found.file_data    === expected.file_data,    "non-instant change pref file"   );
   362       // and these changes should *NOT* get passed to the system
   363       // (which obviously always passes with the above failing)
   364       expected = kPrefValueSet1;
   365       found    = ReadPrefsFromSystem();
   366       ok(found.int          === expected.int,          "non-instant change element int"    );
   367       ok(found.bool         === expected.bool,         "non-instant change element bool"   );
   368       ok(found.string       === expected.string,       "non-instant change element string" );
   369       ok(found.wstring_data === expected.wstring_data, "non-instant change element wstring");
   370       ok(found.unichar_data === expected.unichar_data, "non-instant change element unichar");
   371       todo(found.file_data  === expected.file_data,    "non-instant change element file"   );
   373       // try resetting the prefs to default values (which should be empty here)
   374       GetXULElement(aPrefWindow, "tests.static_preference_int"    ).reset();
   375       GetXULElement(aPrefWindow, "tests.static_preference_bool"   ).reset();
   376       GetXULElement(aPrefWindow, "tests.static_preference_string" ).reset();
   377       GetXULElement(aPrefWindow, "tests.static_preference_wstring").reset();
   378       GetXULElement(aPrefWindow, "tests.static_preference_unichar").reset();
   379       GetXULElement(aPrefWindow, "tests.static_preference_file"   ).reset();
   381       // check system: the current values *MUST NOT* change
   382       expected = kPrefValueSet1;
   383       found    = ReadPrefsFromSystem();
   384       ok(found.int          === expected.int,          "non-instant reset system int"    );
   385       ok(found.bool         === expected.bool,         "non-instant reset system bool"   );
   386       ok(found.string       === expected.string,       "non-instant reset system string" );
   387       ok(found.wstring_data === expected.wstring_data, "non-instant reset system wstring");
   388       ok(found.unichar_data === expected.unichar_data, "non-instant reset system unichar");
   389       todo(found.file_data  === expected.file_data,    "non-instant reset system file"   );
   391       // check UI: these values should be reset
   392       expected =
   393       {
   394         // alas, we don't have XUL elements with typeof(value) == int :(
   395         // int:         0,
   396         int:          "",
   397         bool:         false,
   398         string:       "",
   399         wstring_data: "",
   400         unichar_data: "",
   401         file_data:    "",
   402         wstring:      {},
   403         unichar:      {},
   404         file:         {}
   405       };
   406       found = ReadPrefsFromUI(aPrefWindow);
   407       ok(found.int          === expected.int,          "non-instant reset element int"    );
   408       ok(found.bool         === expected.bool,         "non-instant reset element bool"   );
   409       ok(found.string       === expected.string,       "non-instant reset element string" );
   410       ok(found.wstring_data === expected.wstring_data, "non-instant reset element wstring");
   411       ok(found.unichar_data === expected.unichar_data, "non-instant reset element unichar");
   412 //      ok(found.file_data    === expected.file_data,    "non-instant reset element file"   );
   414       // check hasUserValue
   415       ok(GetXULElement(aPrefWindow, "tests.static_preference_int"    ).hasUserValue === false, "non-instant reset hasUserValue int"    );
   416       ok(GetXULElement(aPrefWindow, "tests.static_preference_bool"   ).hasUserValue === false, "non-instant reset hasUserValue bool"   );
   417       ok(GetXULElement(aPrefWindow, "tests.static_preference_string" ).hasUserValue === false, "non-instant reset hasUserValue string" );
   418       ok(GetXULElement(aPrefWindow, "tests.static_preference_wstring").hasUserValue === false, "non-instant reset hasUserValue wstring");
   419       ok(GetXULElement(aPrefWindow, "tests.static_preference_unichar").hasUserValue === false, "non-instant reset hasUserValue unichar");
   420       ok(GetXULElement(aPrefWindow, "tests.static_preference_file"   ).hasUserValue === false, "non-instant reset hasUserValue file"   );
   421     }
   423     function RunNonInstantPrefTestClose(aPrefWindow)
   424     {
   425       WritePrefsToPreferences(aPrefWindow, kPrefValueSet2);
   426     }
   428     function RunCheckCommandRedirect(aPrefWindow)
   429     {
   430       GetXULElement(aPrefWindow, "checkbox").click();
   431       ok(GetXULElement(aPrefWindow, "tests.static_preference_bool").value, "redirected command bool");
   432       GetXULElement(aPrefWindow, "checkbox").click();
   433       ok(!GetXULElement(aPrefWindow, "tests.static_preference_bool").value, "redirected command bool");
   434     }
   436     function RunResetPrefTest(aPrefWindow)
   437     {
   438       // try resetting the prefs to default values
   439       GetXULElement(aPrefWindow, "tests.static_preference_int"    ).reset();
   440       GetXULElement(aPrefWindow, "tests.static_preference_bool"   ).reset();
   441       GetXULElement(aPrefWindow, "tests.static_preference_string" ).reset();
   442       GetXULElement(aPrefWindow, "tests.static_preference_wstring").reset();
   443       GetXULElement(aPrefWindow, "tests.static_preference_unichar").reset();
   444       GetXULElement(aPrefWindow, "tests.static_preference_file"   ).reset();
   445     }
   447     function InitTestPrefs(aInstantApply)
   448     {
   449       // set instant apply mode and init prefs to set 1
   450       kPref.setBoolPref("browser.preferences.instantApply", aInstantApply);
   451       WritePrefsToSystem(kPrefValueSet1);
   452     }
   454     function RunTestInstant()
   455     {
   456       // test with instantApply
   457       InitTestPrefs(true);
   458       openDialog("window_preferences.xul", "", "modal", RunInstantPrefTest, false);
   460       // - test deferred reset in child window
   461       InitTestPrefs(true);
   462       openDialog("window_preferences2.xul", "", "modal", RunResetPrefTest, false);
   463       expected = kPrefValueSet1;
   464       found    = ReadPrefsFromSystem();
   465       ok(found.int          === expected.int,          "instant reset deferred int"    );
   466       ok(found.bool         === expected.bool,         "instant reset deferred bool"   );
   467       ok(found.string       === expected.string,       "instant reset deferred string" );
   468       ok(found.wstring_data === expected.wstring_data, "instant reset deferred wstring");
   469       ok(found.unichar_data === expected.unichar_data, "instant reset deferred unichar");
   470       todo(found.file_data  === expected.file_data,    "instant reset deferred file"   );
   471     }
   473     function RunTestNonInstant()
   474     {
   475       // test without instantApply
   476       // - general tests, similar to instant apply
   477       InitTestPrefs(false);
   478       openDialog("window_preferences.xul", "", "modal", RunNonInstantPrefTestGeneral, false);
   480       // - test Cancel
   481       InitTestPrefs(false);
   482       openDialog("window_preferences.xul", "", "modal", RunNonInstantPrefTestClose, false);
   483       var expected = kPrefValueSet1;
   484       var found    = ReadPrefsFromSystem();
   485       ok(found.int          === expected.int,          "non-instant cancel system int"    );
   486       ok(found.bool         === expected.bool,         "non-instant cancel system bool"   );
   487       ok(found.string       === expected.string,       "non-instant cancel system string" );
   488       ok(found.wstring_data === expected.wstring_data, "non-instant cancel system wstring");
   489       ok(found.unichar_data === expected.unichar_data, "non-instant cancel system unichar");
   490       todo(found.file_data  === expected.file_data,    "non-instant cancel system file"   );
   492       // - test Accept
   493       InitTestPrefs(false);
   494       openDialog("window_preferences.xul", "", "modal", RunNonInstantPrefTestClose, true);
   495       expected = kPrefValueSet2;
   496       found    = ReadPrefsFromSystem();
   497       ok(found.int          === expected.int,          "non-instant accept system int"    );
   498       ok(found.bool         === expected.bool,         "non-instant accept system bool"   );
   499       ok(found.string       === expected.string,       "non-instant accept system string" );
   500       ok(found.wstring_data === expected.wstring_data, "non-instant accept system wstring");
   501       ok(found.unichar_data === expected.unichar_data, "non-instant accept system unichar");
   502       todo(found.file_data  === expected.file_data,    "non-instant accept system file"   );
   504       // - test deferred reset in child window
   505       InitTestPrefs(false);
   506       openDialog("window_preferences2.xul", "", "modal", RunResetPrefTest, true);
   507       expected = CreateEmptyPrefValueSet();
   508       found    = ReadPrefsFromSystem();
   509       ok(found.int          === expected.int,          "non-instant reset deferred int"    );
   510       ok(found.bool         === expected.bool,         "non-instant reset deferred bool"   );
   511       ok(found.string       === expected.string,       "non-instant reset deferred string" );
   512       ok(found.wstring_data === expected.wstring_data, "non-instant reset deferred wstring");
   513       ok(found.unichar_data === expected.unichar_data, "non-instant reset deferred unichar");
   514       ok(found.file_data    === expected.file_data,    "non-instant reset deferred file"   );
   515     }
   517     function RunTestCommandRedirect()
   518     {
   519       openDialog("window_preferences_commandretarget.xul", "", "modal", RunCheckCommandRedirect, true);
   520     }
   522     function RunTest()
   523     {
   524       RunTestInstant();
   525       RunTestNonInstant();
   526       RunTestCommandRedirect();
   527       SimpleTest.finish();
   528     }
   529   ]]>
   530   </script>
   532   <body xmlns="http://www.w3.org/1999/xhtml">
   533     <p id="display"></p>
   534     <div id="content" style="display: none"></div>
   535     <pre id="test"></pre>
   536   </body>
   538 </window>

mercurial