Bug 470165 - Cleanup the GTK nsFilePicker code; r+sr=roc
[wine-gecko.git] / content / xbl / test / test_bug379959.html
blobda0b8010e1943f969b3bd4571b787eb0ba87d93b
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=366770
5 -->
6 <head>
7 <title>Test for Bug 366770</title>
8 <script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
9 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
11 </head>
12 <body onload="gen.next();">
13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=366770">Mozilla Bug 366770</a>
14 <p id="display">
15 Note: In order to re-run this test correctly you need to shift-reload
16 rather than simply reload. If you just reload we will restore the
17 previous url in the iframe which will result in an extra unexpected
18 message.
19 </p>
20 <div id="content" style="display: none"></div>
21 <iframe id="f"></iframe>
23 <pre id="test">
24 <script class="testbody" type="application/javascript;version=1.7">
25 SimpleTest.waitForExplicitFinish();
27 gen = runTest();
28 var messages = 0;
30 function receiveMessage(e)
32 is(e.origin, "http://localhost:8888", "wrong sender!");
33 messages++;
34 gen.send(e.data);
37 window.addEventListener("message", receiveMessage, false);
39 const prefName = "layout.debug.enable_data_xbl";
41 function runTest() {
42 iframe = document.getElementById('f');
44 // Turn on loads of data-urls
45 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
46 var prefs = Components.classes["@mozilla.org/preferences-service;1"]
47 .getService(Components.interfaces.nsIPrefBranch);
48 var oldPrefVal = undefined;
49 if (prefs.prefHasUserValue(prefName)) {
50 oldPrefVal = prefs.getBoolPref(prefName);
53 // Test with data-urls off
54 prefs.setBoolPref(prefName, false);
55 iframe.src = "file_bug379959_data.html";
56 is((yield), 0, "data-url load should have failed");
58 // Test with data-urls on
59 prefs.setBoolPref(prefName, true);
60 iframe.src = "file_bug379959_data.html";
61 is((yield), 1, "data-url load should have been successful");
63 // Try a cross-site load
64 iframe.src = "file_bug379959_cross.html";
65 is((yield), 1, "same site load should have succeeded");
66 is((yield), 0, "cross site load should have failed");
68 // Check that we got the right number of messages to make sure that
69 // the right message has aligned with the right test
70 is(messages, 4, "wrong number of messages");
72 // We're done
73 if (oldPrefVal === undefined) {
74 prefs.clearUserPref(prefName);
76 else {
77 prefs.setBoolPref(prefName, oldPrefVal);
80 SimpleTest.finish();
82 yield;
84 </script>
85 </pre>
86 </body>
87 </html>