Bug 1833110 - Cache ldconfig to limit main thread io r=jld,Gijs
[gecko.git] / docshell / test / chrome / test_docRedirect.xhtml
blob1688d9823ef389404624a1ea4c5d528606b3dd6f
1 <?xml version="1.0"?>
2 <?xml-stylesheet type="text/css" href="chrome://global/skin"?>
3 <?xml-stylesheet type="text/css" href="/tests/SimpleTest/test.css"?>
4 <!--
5 https://bugzilla.mozilla.org/show_bug.cgi?id=1342989
6 -->
7 <window title="Mozilla Bug 1342989"
8 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
10 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
12 <script type="application/javascript">
13 <![CDATA[
14 SimpleTest.waitForExplicitFinish();
16 const WEB_PROGRESS_LISTENER_FLAGS =
17 Object.keys(Ci.nsIWebProgressListener).filter(
18 propName => propName.startsWith("STATE_")
21 function bitFlagsToNames(flags, knownNames, intf) {
22 return knownNames.map( (F) => {
23 return (flags & intf[F]) ? F : undefined;
24 }).filter( (s) => !!s );
27 var progressListener = {
28 add(docShell, callback) {
29 this.callback = callback;
30 this.docShell = docShell;
31 docShell.
32 QueryInterface(Ci.nsIInterfaceRequestor).
33 getInterface(Ci.nsIWebProgress).
34 addProgressListener(this, Ci.nsIWebProgress.NOTIFY_STATE_ALL);
37 finish(success) {
38 this.docShell.
39 QueryInterface(Ci.nsIInterfaceRequestor).
40 getInterface(Ci.nsIWebProgress).
41 removeProgressListener(this);
42 this.callback(success);
45 onStateChange (webProgress, req, flags, status) {
46 if (!(flags & Ci.nsIWebProgressListener.STATE_IS_DOCUMENT) &&
47 !(flags & Ci.nsIWebProgressListener.STATE_IS_REDIRECTED_DOCUMENT))
48 return;
50 var channel = req.QueryInterface(Ci.nsIChannel);
52 if (flags & Ci.nsIWebProgressListener.STATE_IS_REDIRECTED_DOCUMENT) {
53 SimpleTest.is(channel.URI.host, "example.org",
54 "Should be redirected to example.org (see test_docRedirect.sjs)");
55 this.finish(true);
58 // Fail in case we didn't receive document redirection event.
59 if (flags & Ci.nsIWebProgressListener.STATE_STOP)
60 this.finish(false);
63 QueryInterface: ChromeUtils.generateQI([
64 "nsIWebProgressListener",
65 "nsISupportsWeakReference",
66 ]),
69 var webNav = SpecialPowers.Services.appShell.createWindowlessBrowser(true);
70 let docShell = webNav.docShell;
71 let system = Cc["@mozilla.org/systemprincipal;1"].getService(Ci.nsIPrincipal);
72 docShell.createAboutBlankContentViewer(system, system);
74 progressListener.add(docShell, function(success) {
75 webNav.close();
76 SimpleTest.is(success, true, "Received document redirect event");
77 SimpleTest.finish();
78 });
80 var win = docShell.contentViewer.DOMDocument.defaultView;
81 // eslint-disable-next-line @microsoft/sdl/no-insecure-url
82 win.location = "http://example.com/chrome/docshell/test/chrome/test_docRedirect.sjs"
84 ]]>
85 </script>
87 <body xmlns="http://www.w3.org/1999/xhtml">
88 <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1342989"
89 target="_blank">Mozilla Bug 1342989</a>
90 </body>
91 </window>