4 if (window.layoutTestController) {
5 layoutTestController.dumpAsText();
6 layoutTestController.waitUntilDone();
14 res1 = document.getElementById("result1");
15 res2 = document.getElementById("result2");
16 plg.getURLNotify("/plugins/resources/load-me-2.txt", null, "callback");
18 showErr("Exception: " + ex.description);
19 if (window.layoutTestController)
20 layoutTestController.notifyDone();
24 function callback(errCode, streamDump)
26 var parse = parseStreamDump(streamDump);
30 res1.innerHTML = newlinesToHTML(parse.res1);
31 res2.innerHTML = newlinesToHTML(parse.res2);
34 if (window.layoutTestController)
35 layoutTestController.notifyDone();
38 // Format passed by plugin: four fields separated by \n\n:
39 // First URL; first header block; last URL; last header block.
40 function parseStreamDump(streamDump)
44 if (typeof streamDump == "string" || ((typeof streamDump == "object") && (streamDump.constructor == String))) {
45 var parts = streamDump.split("\n\n");
46 if (parts.length >= 4) {
47 rtn.res1 = genericURL(parts[0]) + "\n" + parseHeaders(parts[1]);
48 rtn.res2 = genericURL(parts[2]) + "\n" + parseHeaders(parts[3]);
50 rtn.err = "streamDump from plugin does not have expected format";
52 rtn.err = "streamDump from plugin is not a string: " + streamDump;
59 res1.innerHTML = "FAILED - " + err;
63 function newlinesToHTML(str)
65 return str.replace(/\n/g, "<br>");
68 function genericURL(url)
70 return url.replace(/^(http:\/\/)[^\/]+/, "$1[varies, not being tested]");
73 function parseHeaders(hdrs)
75 var parts = hdrs.split("\n");
76 var rtn = parts[0] + "\n";
78 for (var i = 0; i < parts.length; i++)
79 if (parts[i].match(/^Content-Type:/))
86 <body onload="test()">
87 <embed name="plg" type="application/x-webkit-test-netscape" src="/plugins/resources/load-me-1.txt"></embed>
88 <p>Test for <a href="http://bugzilla.opendarwin.org/show_bug.cgi?id=13029">bug 13029<a/>:
89 Permit NPAPI plug-ins to see HTTP response headers.</p>
90 <p>Expected result below is two HTTP response extracts, one for the initial stream specified in the "src"
91 attribute, the other for an NPN_GetURLNotify request. Each block should contain the URL; the status line,
92 which should say "HTTP 200 OK"; and the MIME-type, which should say "Content-Type: text/plain".</p>
94 <p id="result1">Running test, result should appear here in a very short time...</p>
96 <p id="result2">Running test, result should appear here in a very short time...</p>