| OLD | NEW |
| 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 } |
| 11 | 11 |
| 12 function DidExecuteTests() { | 12 function DidExecuteTests() { |
| 13 var plugin = document.getElementById("plugin"); |
| 14 plugin.parentNode.removeChild(plugin); |
| 15 plugin = undefined; |
| 16 CheckPostConditions(); |
| 17 |
| 13 if (window == top) | 18 if (window == top) |
| 14 return; | 19 return; |
| 15 | 20 |
| 16 // Otherwise, we are in a subframe, so we can use this opportunity to resize | 21 // Otherwise, we are in a subframe, so we can use this opportunity to resize |
| 17 // ourselves. | 22 // ourselves. |
| 18 AdjustHeight(window); | 23 AdjustHeight(window); |
| 19 } | 24 } |
| 20 | 25 |
| 21 function AppendFrame(testcase, i) { | 26 function AppendFrame(testcase, i) { |
| 22 var p = document.createElement("P"); | 27 var p = document.createElement("P"); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 // If the message_data is not a string or does not match the above format, then | 77 // If the message_data is not a string or does not match the above format, then |
| 73 // undefined is returned. | 78 // undefined is returned. |
| 74 // | 79 // |
| 75 // Otherwise, returns an array containing 2 items. The 0th element is the | 80 // Otherwise, returns an array containing 2 items. The 0th element is the |
| 76 // message_type, one of: | 81 // message_type, one of: |
| 77 // - ClearContents | 82 // - ClearContents |
| 78 // - DidExecuteTests | 83 // - DidExecuteTests |
| 79 // - LogHTML | 84 // - LogHTML |
| 80 // - SetCookie | 85 // - SetCookie |
| 81 // - EvalScript | 86 // - EvalScript |
| 87 // - AddPostCondition |
| 82 // The second item is the verbatim message_contents. | 88 // The second item is the verbatim message_contents. |
| 83 function ParseTestingMessage(message_data) { | 89 function ParseTestingMessage(message_data) { |
| 84 if (typeof(message_data)!='string') | 90 if (typeof(message_data) != "string") |
| 85 return undefined; | 91 return undefined; |
| 86 var testing_message_prefix = "TESTING_MESSAGE"; | 92 var testing_message_prefix = "TESTING_MESSAGE"; |
| 87 var delim_str = ":"; | 93 var delim_str = ":"; |
| 88 var delim1 = message_data.indexOf(delim_str); | 94 var delim1 = message_data.indexOf(delim_str); |
| 89 if (message_data.substring(0, delim1) !== testing_message_prefix) | 95 if (message_data.substring(0, delim1) !== testing_message_prefix) |
| 90 return undefined; | 96 return undefined; |
| 91 var delim2 = message_data.indexOf(delim_str, delim1 + 1); | 97 var delim2 = message_data.indexOf(delim_str, delim1 + 1); |
| 92 if (delim2 == -1) | 98 if (delim2 == -1) |
| 93 delim2 = message_data.length; | 99 delim2 = message_data.length; |
| 94 var message_type = message_data.substring(delim1 + 1, delim2); | 100 var message_type = message_data.substring(delim1 + 1, delim2); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 108 window.document.cookie = key_value_string + "; path=/"; | 114 window.document.cookie = key_value_string + "; path=/"; |
| 109 } | 115 } |
| 110 | 116 |
| 111 function EvalScript(script) { | 117 function EvalScript(script) { |
| 112 try { | 118 try { |
| 113 eval(script); | 119 eval(script); |
| 114 } catch(ex) { | 120 } catch(ex) { |
| 115 } | 121 } |
| 116 } | 122 } |
| 117 | 123 |
| 124 var conditions = []; |
| 125 // Add a "PostCondition". These are bits of script that are run after the plugin |
| 126 // is destroyed. If they evaluate to false or throw an exception, it's |
| 127 // considered a failure. |
| 128 function AddPostCondition(script) { |
| 129 conditions.push(script); |
| 130 } |
| 131 // Update the HTML to show the failure and update cookies so that ui_tests |
| 132 // doesn't count this as a pass. |
| 133 function ConditionFailed(error) { |
| 134 error_string = "Post condition check failed: " + error; |
| 135 var i = 0; |
| 136 // If the plugin thinks the test passed but a post-condition failed, we want |
| 137 // to clear the PASS cookie so that ui_tests doesn't count it is a passed |
| 138 // test. |
| 139 if (window.document.cookie.indexOf("PASS") != -1) { |
| 140 while (window.document.cookie.indexOf("PPAPI_PROGRESS_" + i) != -1) { |
| 141 window.document.cookie = "PPAPI_PROGRESS_" + i + "=; max-age=0"; |
| 142 ++i; |
| 143 } |
| 144 window.document.cookie = "PPAPI_PROGRESS_0=" + error_string |
| 145 } |
| 146 LogHTML("<p>" + error_string); |
| 147 } |
| 148 // Iterate through the post conditions defined in |conditions| and check that |
| 149 // they all pass. |
| 150 function CheckPostConditions() { |
| 151 for (var i = 0; i < conditions.length; ++i) { |
| 152 var script = conditions[i]; |
| 153 try { |
| 154 if (!eval(script)) { |
| 155 ConditionFailed("\"" + script + "\""); |
| 156 } |
| 157 } catch (ex) { |
| 158 ConditionFailed("\"" + script + "\"" + " failed with exception: " + |
| 159 "\"" + ex.toString() + "\""); |
| 160 } |
| 161 } |
| 162 } |
| 163 |
| 118 function IsTestingMessage(message_data) { | 164 function IsTestingMessage(message_data) { |
| 119 return (ParseTestingMessage(message_data) != undefined); | 165 return (ParseTestingMessage(message_data) != undefined); |
| 120 } | 166 } |
| 121 | 167 |
| 122 function handleTestingMessage(message_event) { | 168 function handleTestingMessage(message_event) { |
| 123 var type_contents_tuple = ParseTestingMessage(message_event.data); | 169 var type_contents_tuple = ParseTestingMessage(message_event.data); |
| 124 if (type_contents_tuple) { | 170 if (type_contents_tuple) { |
| 125 var type = type_contents_tuple[0]; | 171 var type = type_contents_tuple[0]; |
| 126 var contents = type_contents_tuple[1]; | 172 var contents = type_contents_tuple[1]; |
| 127 if (type === "ClearConsole") | 173 if (type === "ClearConsole") |
| 128 ClearConsole(); | 174 ClearConsole(); |
| 129 else if (type === "DidExecuteTests") | 175 else if (type === "DidExecuteTests") |
| 130 DidExecuteTests(); | 176 DidExecuteTests(); |
| 131 else if (type === "LogHTML") | 177 else if (type === "LogHTML") |
| 132 LogHTML(contents); | 178 LogHTML(contents); |
| 133 else if (type === "SetCookie") | 179 else if (type === "SetCookie") |
| 134 SetCookie(contents); | 180 SetCookie(contents); |
| 135 else if (type === "EvalScript") | 181 else if (type === "EvalScript") |
| 136 EvalScript(contents); | 182 EvalScript(contents); |
| 183 else if (type == "AddPostCondition") |
| 184 AddPostCondition(contents); |
| 137 } | 185 } |
| 138 } | 186 } |
| 139 | 187 |
| 140 onload = function() { | 188 onload = function() { |
| 141 var testcase = ExtractSearchParameter("testcase"); | 189 var testcase = ExtractSearchParameter("testcase"); |
| 142 var mode = ExtractSearchParameter("mode"); | 190 var mode = ExtractSearchParameter("mode"); |
| 143 document.title = 'Test ' + testcase; | 191 document.title = 'Test ' + testcase; |
| 144 var obj; | 192 var obj; |
| 145 if (mode == "nacl") { | 193 if (mode == "nacl") { |
| 146 obj = document.createElement("EMBED"); | 194 obj = document.createElement("EMBED"); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 177 container.appendChild(obj); | 225 container.appendChild(obj); |
| 178 } | 226 } |
| 179 } | 227 } |
| 180 | 228 |
| 181 // EVIL Note: | 229 // EVIL Note: |
| 182 // This part of the script does some nefarious things to make sure that it | 230 // This part of the script does some nefarious things to make sure that it |
| 183 // doesn't affect the behavior of PostMessage (on which all the tests rely). In | 231 // doesn't affect the behavior of PostMessage (on which all the tests rely). In |
| 184 // particular, we replace document.createEvent, MessageEvent.initMessageEvent, | 232 // particular, we replace document.createEvent, MessageEvent.initMessageEvent, |
| 185 // and the MessageEvent constructor. Previous versions of the PostMessage | 233 // and the MessageEvent constructor. Previous versions of the PostMessage |
| 186 // implementation made use of these and would fail (http://crbug.com/82604). | 234 // implementation made use of these and would fail (http://crbug.com/82604). |
| 235 // TODO(dmichael): These should clear the PASS cookie so that ui_tests sees |
| 236 // these as a failure (see ConditionFailed for how to do this). |
| 237 // crbug.com/109775 |
| 187 document.createEvent = function() { | 238 document.createEvent = function() { |
| 188 LogHTML("<p>Bad document.createEvent called!"); | 239 LogHTML("<p>Bad document.createEvent called!"); |
| 189 } | 240 } |
| 190 function MessageEvent() { | 241 function MessageEvent() { |
| 191 LogHTML("<p>Bad MessageEvent constructor called!"); | 242 LogHTML("<p>Bad MessageEvent constructor called!"); |
| 192 } | 243 } |
| 193 MessageEvent.prototype.initMessageEvent = function() { | 244 MessageEvent.prototype.initMessageEvent = function() { |
| 194 LogHTML("<p>Bad MessageEvent.initMessageEvent called!"); | 245 LogHTML("<p>Bad MessageEvent.initMessageEvent called!"); |
| 195 } | 246 } |
| 196 | 247 |
| 197 </script> | 248 </script> |
| 198 </head><body> | 249 </head><body> |
| 199 <div> | 250 <div> |
| 200 <div id="container"></div> | 251 <div id="container"></div> |
| 201 <div id="console" /><span class="load_msg">loading...</span></div> | 252 <div id="console" /><span class="load_msg">loading...</span></div> |
| 202 </div> | 253 </div> |
| 203 </body></html> | 254 </body></html> |
| OLD | NEW |