OLD | NEW |
| (Empty) |
1 <html> | |
2 <head> | |
3 <script> | |
4 if (window.testRunner) { | |
5 testRunner.dumpAsText(); | |
6 testRunner.waitUntilDone(); | |
7 } | |
8 | |
9 loadedFirstURL = false; | |
10 | |
11 var res1, res2; | |
12 | |
13 function test() | |
14 { | |
15 try { | |
16 res1 = document.getElementById("result1"); | |
17 res2 = document.getElementById("result2"); | |
18 } catch (ex) { | |
19 showErr("Exception: " + ex.description); | |
20 if (window.testRunner) | |
21 testRunner.notifyDone(); | |
22 } | |
23 } | |
24 | |
25 function streamLoaded() | |
26 { | |
27 if (loadedFirstURL) | |
28 return; | |
29 | |
30 loadedFirstURL = true; | |
31 plg.getURLNotify("/plugins/resources/load-me-2.txt", null, "callback"); | |
32 } | |
33 | |
34 function callback(errCode, streamDump) | |
35 { | |
36 var parse = parseStreamDump(streamDump); | |
37 if (parse.err) | |
38 showErr(parse.err); | |
39 else { | |
40 res1.innerHTML = newlinesToHTML(parse.res1); | |
41 res2.innerHTML = newlinesToHTML(parse.res2); | |
42 } | |
43 | |
44 if (window.testRunner) | |
45 testRunner.notifyDone(); | |
46 } | |
47 | |
48 // Format passed by plugin: four fields separated by \n\n: | |
49 // First URL; first header block; last URL; last header block. | |
50 function parseStreamDump(streamDump) | |
51 { | |
52 var rtn = {}; | |
53 | |
54 if (typeof streamDump == "string" || ((typeof streamDump == "object") && (st
reamDump.constructor == String))) { | |
55 var parts = streamDump.split("\n\n"); | |
56 if (parts.length >= 4) { | |
57 rtn.res1 = genericURL(parts[0]) + "\n" + parseHeaders(parts[1]); | |
58 rtn.res2 = genericURL(parts[2]) + "\n" + parseHeaders(parts[3]); | |
59 } else | |
60 rtn.err = "streamDump from plugin does not have expected format"; | |
61 } else | |
62 rtn.err = "streamDump from plugin is not a string: " + streamDump; | |
63 | |
64 return rtn; | |
65 } | |
66 | |
67 function showErr(err) | |
68 { | |
69 res1.innerHTML = "FAILED - " + err; | |
70 res2.innerHTML = ""; | |
71 } | |
72 | |
73 function newlinesToHTML(str) | |
74 { | |
75 return str.replace(/\n/g, "<br>"); | |
76 } | |
77 | |
78 function genericURL(url) | |
79 { | |
80 return url.replace(/^(http:\/\/)[^\/]+/, "$1[varies, not being tested]"); | |
81 } | |
82 | |
83 function parseHeaders(hdrs) | |
84 { | |
85 var parts = hdrs.split("\n"); | |
86 var rtn = parts[0] + "\n"; | |
87 | |
88 for (var i = 0; i < parts.length; i++) | |
89 if (parts[i].match(/^Content-Type:/)) | |
90 rtn += parts[i]; | |
91 | |
92 return rtn; | |
93 } | |
94 </script> | |
95 </head> | |
96 <body onload="test()"> | |
97 <embed name="plg" type="application/x-webkit-test-netscape" src="/plugins/resour
ces/load-me-1.txt" onstreamload="streamLoaded()"></embed> | |
98 <p>Test for <a href="https://bugs.webkit.org/show_bug.cgi?id=13029">bug 13029<a/
>: | |
99 Permit NPAPI plugins to see HTTP response headers.</p> | |
100 <p>Expected result below is two HTTP response extracts, one for the initial stre
am specified in the "src" | |
101 attribute, the other for an NPN_GetURLNotify request. Each block should contain
the URL; the status line, | |
102 which should say "HTTP 200 OK"; and the MIME-type, which should say "Content-Typ
e: text/plain".</p> | |
103 <p>----------</p> | |
104 <p id="result1">Running test, result should appear here in a very short time...<
/p> | |
105 <p>----------</p> | |
106 <p id="result2">Running test, result should appear here in a very short time...<
/p> | |
107 </body> | |
108 </html> | |
OLD | NEW |