4 https://bugzilla.mozilla.org/show_bug.cgi?id=366770
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" />
12 <body onload=
"gen.next();">
13 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=366770">Mozilla Bug
366770</a>
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
20 <div id=
"content" style=
"display: none"></div>
21 <iframe id=
"f"></iframe>
24 <script class=
"testbody" type=
"application/javascript;version=1.7">
25 SimpleTest.waitForExplicitFinish();
30 function receiveMessage(e)
32 is(e.origin,
"http://localhost:8888",
"wrong sender!");
37 window.addEventListener(
"message", receiveMessage, false);
39 const prefName =
"layout.debug.enable_data_xbl";
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");
73 if (oldPrefVal === undefined) {
74 prefs.clearUserPref(prefName);
77 prefs.setBoolPref(prefName, oldPrefVal);