Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / chrome / test / data / load_pepper_plugin.html
blobd1103a8e60f5016218b9e762b05446d62e7edefe
1 <html>
2 <head>
3 <title>Initial Title</title>
4 <script>
5 var QueryString = function() {
6 // Allows access to query parameters on the URL; e.g., given a URL like:
7 // http://<server>/my.html?test=123&bob=123
8 // Parameters can then be accessed via QueryString.test or QueryString.bob.
9 var params = {};
10 // RegEx to split out values by &.
11 var r = /([^&=]+)=?([^&]*)/g;
12 // Lambda function for decoding extracted match values. Replaces '+' with
13 // space so decodeURIComponent functions properly.
14 function d(s) { return decodeURIComponent(s.replace(/\+/g, ' ')); }
15 var match;
16 while (match = r.exec(window.location.search.substring(1)))
17 params[d(match[1])] = d(match[2]);
18 return params;
19 }();
21 var mimeType = QueryString.mimetype;
23 function inject() {
24 var child = document.createElement('div');
25 child.innerHTML = '<object type="' + mimeType + '" id="plugin" border=1>' +
26 ' <b>You should not see this text!</b>' +
27 '</object>';
28 document.getElementById('content').appendChild(child);
29 // Plugins are loaded synchronously during layout, so the plugin has either
30 // been loaded or blocked at this point.
31 var plugin = document.getElementById('plugin');
32 try {
33 // All Pepper plugins support postMessage().
34 // If postMessage is undefined, the plugin is not loaded.
35 if (plugin.postMessage == undefined) {
36 document.title = 'Not Loaded';
37 return;
40 plugin.postMessage('hello');
41 // If we do not get an exception, the Pepper plugin is loaded.
42 document.title = 'Loaded';
43 } catch (e) {
44 var errorMessage = 'Unexpected Exception: ' + e.toString();
45 document.title = errorMessage;
46 console.log(errorMessage);
49 </script>
50 </head>
51 <body onload='inject();'>
52 <div id='content'></div>
53 </body>
54 </html>