OLD | NEW |
(Empty) | |
| 1 <html> |
| 2 <head> |
| 3 <meta http-equiv="x-ua-compatible" content="chrome=1" /> |
| 4 <script type="text/javascript" src="chrome_frame_tester_helpers.js"> |
| 5 </script> |
| 6 <script> |
| 7 // Default text value used to test cut/copy/paste etc. |
| 8 var INIT_VAL = "SomeInitializedTextValue"; |
| 9 |
| 10 // Get selected text value in text field. |
| 11 function getSelectionInTextField(id) { |
| 12 var textField = document.getElementById(id); |
| 13 var selectedValue = textField.value.substring(textField.selectionStart, |
| 14 textField.selectionEnd); |
| 15 return selectedValue; |
| 16 } |
| 17 |
| 18 function isExpectedResult(action) { |
| 19 var txtFieldVal = document.getElementById("textField").value; |
| 20 var res = false; |
| 21 |
| 22 switch (action) { |
| 23 case "selectall": |
| 24 if (getSelectionInTextField("textField") == INIT_VAL) { |
| 25 res = true; |
| 26 } else { |
| 27 res = false; |
| 28 } |
| 29 break; |
| 30 } |
| 31 return res; |
| 32 } |
| 33 |
| 34 // Verify the expected result based on action and post message to host. |
| 35 function verifyTextFieldContents(event) { |
| 36 var action = event.data; |
| 37 |
| 38 if (isExpectedResult(action)) { |
| 39 window.externalHost.postMessage("OK"); |
| 40 } else { |
| 41 window.externalHost.postMessage("Fail"); |
| 42 } |
| 43 } |
| 44 |
| 45 // Do some initialization work like setting text field value, |
| 46 // and selecting the value by default before the test starts. |
| 47 function init() { |
| 48 var action = getURLParameter("action"); |
| 49 |
| 50 document.getElementById("textField").value = INIT_VAL; |
| 51 document.getElementById("textField").focus(); |
| 52 if (action != "selectall") { |
| 53 document.getElementById("textField").select(); |
| 54 } |
| 55 |
| 56 window.externalHost.onmessage = verifyTextFieldContents; |
| 57 } |
| 58 </script> |
| 59 </head> |
| 60 |
| 61 <body leftmargin="0" topmargin="0" onload="init()"> |
| 62 <input type="text" name="textField" id="textField" size="25" value=""></td> |
| 63 </body> |
| 64 </html> |
| 65 |
OLD | NEW |