4 if (window
.testRunner
) {
5 testRunner
.dumpAsText();
6 testRunner
.waitUntilDone();
9 loadedFirstURL
= false;
16 res1
= document
.getElementById("result1");
17 res2
= document
.getElementById("result2");
19 showErr("Exception: " + ex
.description
);
20 if (window
.testRunner
)
21 testRunner
.notifyDone();
25 function streamLoaded()
30 loadedFirstURL
= true;
31 plg
.getURLNotify("/plugins/resources/load-me-2.txt", null, "callback");
34 function callback(errCode
, streamDump
)
36 var parse
= parseStreamDump(streamDump
);
40 res1
.innerHTML
= newlinesToHTML(parse
.res1
);
41 res2
.innerHTML
= newlinesToHTML(parse
.res2
);
44 if (window
.testRunner
)
45 testRunner
.notifyDone();
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
)
54 if (typeof streamDump
== "string" || ((typeof streamDump
== "object") && (streamDump
.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]);
60 rtn
.err
= "streamDump from plugin does not have expected format";
62 rtn
.err
= "streamDump from plugin is not a string: " + streamDump
;
69 res1
.innerHTML
= "FAILED - " + err
;
73 function newlinesToHTML(str
)
75 return str
.replace(/\n/g, "<br>");
78 function genericURL(url
)
80 return url
.replace(/^(http:\/\/)[^\/]+/, "$1[varies, not being tested]");
83 function parseHeaders(hdrs
)
85 var parts
= hdrs
.split("\n");
86 var rtn
= parts
[0] + "\n";
88 for (var i
= 0; i
< parts
.length
; i
++)
89 if (parts
[i
].match(/^Content-Type:/))
96 <body onload=
"test()">
97 <embed name=
"plg" type=
"application/x-webkit-test-netscape" src=
"/plugins/resources/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 stream 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-Type: text/plain".
</p>
104 <p id=
"result1">Running test, result should appear here in a very short time...
</p>
106 <p id=
"result2">Running test, result should appear here in a very short time...
</p>