Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(472)

Side by Side Diff: ppapi/tests/test_case.html

Issue 7312008: Porting ppapi_tests framework to postMessage. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Disable Scrollbar test on Mac for now, merge Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/tests/test_case.cc ('k') | ppapi/tests/test_post_message.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <html><head> 1 <html><head>
2 <meta http-equiv="Pragma" content="no-cache" /> 2 <meta http-equiv="Pragma" content="no-cache" />
3 <meta http-equiv="Expires" content="-1" /> 3 <meta http-equiv="Expires" content="-1" />
4 <link rel="stylesheet" href="test_page.css"> 4 <link rel="stylesheet" href="test_page.css">
5 <script> 5 <script>
6 function AdjustHeight(frameWin) { 6 function AdjustHeight(frameWin) {
7 var div = frameWin.document.getElementsByTagName("div")[0]; 7 var div = frameWin.document.getElementsByTagName("div")[0];
8 var height = frameWin.getComputedStyle(div).height; 8 var height = frameWin.getComputedStyle(div).height;
9 frameWin.frameElement.style.height = height; 9 frameWin.frameElement.style.height = height;
10 } 10 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 if (nameIndex != -1) { 59 if (nameIndex != -1) {
60 var value = location.search.substring(nameIndex + name.length + 1); 60 var value = location.search.substring(nameIndex + name.length + 1);
61 var endIndex = value.indexOf("&"); 61 var endIndex = value.indexOf("&");
62 if (endIndex != -1) 62 if (endIndex != -1)
63 value = value.substring(0, endIndex); 63 value = value.substring(0, endIndex);
64 return value; 64 return value;
65 } 65 }
66 return ""; 66 return "";
67 } 67 }
68 68
69 // Parses the message, looking for strings of the form:
70 // TESTING_MESSAGE:<message_type>:<message_contents>
71 //
72 // If the message_data is not a string or does not match the above format, then
73 // undefined is returned.
74 //
75 // Otherwise, returns an array containing 2 items. The 0th element is the
76 // message_type, one of:
77 // - ClearContents
78 // - DidExecuteTests
79 // - LogHTML
80 // - SetCookie
81 // The second item is the verbatim message_contents.
82 function ParseTestingMessage(message_data) {
83 if (typeof(message_data)!='string')
84 return undefined;
85 var testing_message_prefix = "TESTING_MESSAGE";
86 var delim_str = ":";
87 var delim1 = message_data.indexOf(delim_str);
88 if (message_data.substring(0, delim1) !== testing_message_prefix)
89 return undefined;
90 var delim2 = message_data.indexOf(delim_str, delim1 + 1);
91 if (delim2 == -1)
92 delim2 = message_data.length;
93 var message_type = message_data.substring(delim1 + 1, delim2);
94 var message_contents = message_data.substring(delim2 + 1);
95 return [message_type, message_contents];
96 }
97
98 function ClearConsole() {
99 window.document.getElementById("console").innerHTML = "";
100 }
101
102 function LogHTML(html) {
103 window.document.getElementById("console").innerHTML += html;
104 }
105
106 function SetCookie(key_value_string) {
107 window.document.cookie = key_value_string + "; path=/";
108 }
109
110 function IsTestingMessage(message_data) {
111 return (ParseTestingMessage(message_data) != undefined);
112 }
113
114 function handleTestingMessage(message_event) {
115 var type_contents_tuple = ParseTestingMessage(message_event.data);
116 if (type_contents_tuple) {
117 var type = type_contents_tuple[0];
118 var contents = type_contents_tuple[1];
119 if (type === "ClearConsole")
120 ClearConsole();
121 else if (type === "DidExecuteTests")
122 DidExecuteTests();
123 else if (type === "LogHTML")
124 LogHTML(contents);
125 else if (type === "SetCookie")
126 SetCookie(contents);
127 }
128 }
129
69 onload = function() { 130 onload = function() {
70 var testcase = ExtractSearchParameter("testcase"); 131 var testcase = ExtractSearchParameter("testcase");
71 var mode = ExtractSearchParameter("mode"); 132 var mode = ExtractSearchParameter("mode");
72 document.title = 'Test ' + testcase; 133 document.title = 'Test ' + testcase;
73 var obj; 134 var obj;
74 if (mode == "nacl") { 135 if (mode == "nacl") {
75 obj = document.createElement("EMBED"); 136 obj = document.createElement("EMBED");
76 obj.setAttribute("src", "test_case.nmf"); 137 obj.setAttribute("src", "test_case.nmf");
77 obj.setAttribute("type", "application/x-nacl"); 138 obj.setAttribute("type", "application/x-nacl");
78 obj.setAttribute("mode", mode); 139 obj.setAttribute("mode", mode);
79 } else { 140 } else {
80 var mimeType = "application/x-ppapi-tests"; 141 var mimeType = "application/x-ppapi-tests";
81 if (mimeType in navigator.mimeTypes) { 142 if (mimeType in navigator.mimeTypes) {
82 obj = document.createElement("EMBED"); 143 obj = document.createElement("EMBED");
83 obj.setAttribute("src", "http://a.b.c/test"); 144 obj.setAttribute("src", "http://a.b.c/test");
84 obj.setAttribute("type", mimeType); 145 obj.setAttribute("type", mimeType);
85 } else { 146 } else {
86 document.getElementById("console").innerHTML = 147 document.getElementById("console").innerHTML =
87 '<span class="fail">FAIL</span>: ' + 148 '<span class="fail">FAIL</span>: ' +
88 '<span class="err_msg">Test plug-in is not registered.</span>'; 149 '<span class="err_msg">Test plug-in is not registered.</span>';
89 } 150 }
90 } 151 }
91 if (obj) { 152 if (obj) {
92 obj.setAttribute("id", "plugin"); 153 obj.setAttribute("id", "plugin");
93 obj.setAttribute("testcase", testcase); 154 obj.setAttribute("testcase", testcase);
94 document.getElementById("container").appendChild(obj); 155 obj.setAttribute("protocol", window.location.protocol);
156 var container = document.getElementById("container");
157 container.appendChild(obj);
158 container.addEventListener("message", handleTestingMessage, true);
95 } 159 }
96 } 160 }
97 </script> 161 </script>
98 </head><body> 162 </head><body>
99 <div> 163 <div>
100 <div id="container"></div> 164 <div id="container"></div>
101 <div id="console" /><span class="load_msg">loading...</span></div> 165 <div id="console" /><span class="load_msg">loading...</span></div>
102 </div> 166 </div>
103 </body></html> 167 </body></html>
OLDNEW
« no previous file with comments | « ppapi/tests/test_case.cc ('k') | ppapi/tests/test_post_message.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698