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

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

Issue 7329024: Revert 91859 - Porting ppapi_tests framework to postMessage. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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
130 onload = function() { 69 onload = function() {
131 var testcase = ExtractSearchParameter("testcase"); 70 var testcase = ExtractSearchParameter("testcase");
132 var mode = ExtractSearchParameter("mode"); 71 var mode = ExtractSearchParameter("mode");
133 document.title = 'Test ' + testcase; 72 document.title = 'Test ' + testcase;
134 var obj; 73 var obj;
135 if (mode == "nacl") { 74 if (mode == "nacl") {
136 obj = document.createElement("EMBED"); 75 obj = document.createElement("EMBED");
137 obj.setAttribute("src", "test_case.nmf"); 76 obj.setAttribute("src", "test_case.nmf");
138 obj.setAttribute("type", "application/x-nacl"); 77 obj.setAttribute("type", "application/x-nacl");
139 obj.setAttribute("mode", mode); 78 obj.setAttribute("mode", mode);
140 } else { 79 } else {
141 var mimeType = "application/x-ppapi-tests"; 80 var mimeType = "application/x-ppapi-tests";
142 if (mimeType in navigator.mimeTypes) { 81 if (mimeType in navigator.mimeTypes) {
143 obj = document.createElement("EMBED"); 82 obj = document.createElement("EMBED");
144 obj.setAttribute("src", "http://a.b.c/test"); 83 obj.setAttribute("src", "http://a.b.c/test");
145 obj.setAttribute("type", mimeType); 84 obj.setAttribute("type", mimeType);
146 } else { 85 } else {
147 document.getElementById("console").innerHTML = 86 document.getElementById("console").innerHTML =
148 '<span class="fail">FAIL</span>: ' + 87 '<span class="fail">FAIL</span>: ' +
149 '<span class="err_msg">Test plug-in is not registered.</span>'; 88 '<span class="err_msg">Test plug-in is not registered.</span>';
150 } 89 }
151 } 90 }
152 if (obj) { 91 if (obj) {
153 obj.setAttribute("id", "plugin"); 92 obj.setAttribute("id", "plugin");
154 obj.setAttribute("testcase", testcase); 93 obj.setAttribute("testcase", testcase);
155 obj.setAttribute("protocol", window.location.protocol); 94 document.getElementById("container").appendChild(obj);
156 var container = document.getElementById("container");
157 container.appendChild(obj);
158 container.addEventListener("message", handleTestingMessage, true);
159 } 95 }
160 } 96 }
161 </script> 97 </script>
162 </head><body> 98 </head><body>
163 <div> 99 <div>
164 <div id="container"></div> 100 <div id="container"></div>
165 <div id="console" /><span class="load_msg">loading...</span></div> 101 <div id="console" /><span class="load_msg">loading...</span></div>
166 </div> 102 </div>
167 </body></html> 103 </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