OLD | NEW |
1 <!DOCTYPE html> | 1 <script src="../editing.js"></script> |
2 <script src="../../resources/testharness.js"></script> | |
3 <script src="../../resources/testharnessreport.js"></script> | |
4 | 2 |
5 <script> | 3 <script> |
| 4 function log(message) { |
| 5 var console = document.getElementById("console"); |
| 6 var li = document.createElement("li"); |
| 7 var text = document.createTextNode(message); |
| 8 li.appendChild(text); |
| 9 console.appendChild(li); |
| 10 } |
| 11 |
6 function part1() { | 12 function part1() { |
7 add_result_callback(function(result) { | 13 frames['iframe'].document.body.focus(); |
8 if (result.status == result.PASS) | 14 |
9 window.location = window.location.toString() + '?part2'; | 15 // Hack to perform the editing command. Should be able to |
10 }); | 16 // call execCommand on the main document. |
| 17 frames['iframe'].document.execCommand('InsertText', false, 'c'); |
11 | 18 |
12 test(function() { | 19 if (frames['iframe'].document.body.innerText != 'c') { |
13 frames['iframe'].document.body.focus(); | 20 log("FAIL: could not insert text."); |
14 frames['iframe'].document.execCommand('InsertText', false, 'c'); | 21 if (window.testRunner) |
| 22 testRunner.notifyDone(); |
| 23 return; |
| 24 } |
15 | 25 |
16 assert_equals(frames['iframe'].document.body.innerText, 'c', | 26 if (!document.queryCommandEnabled('Undo')) { |
17 'Text should be inserted into the subframe.'); | 27 log("FAIL: Undo is not enabled after text insertion."); |
| 28 if (window.testRunner) |
| 29 testRunner.notifyDone(); |
| 30 return; |
| 31 } |
18 | 32 |
19 assert_false(document.queryCommandEnabled('Undo'), | 33 window.location = window.location.toString() + "?part2"; |
20 'Undo should not be enabled in main document by text insert
ion in subframe.'); | |
21 }, 'Checks with modification in the subframe.'); | |
22 } | 34 } |
23 | 35 |
24 function part2() { | 36 function part2() { |
25 test(function() { | 37 if (frames['iframe'].document.body.innerText != '') |
26 assert_equals(frames['iframe'].document.body.innerText, '', | 38 log("FAIL: subframe still has old content after navigaiton."); |
27 'Subframe should not have old content after navigaiton.'); | |
28 | 39 |
29 assert_false(document.queryCommandEnabled('Undo'), | 40 if (!document.queryCommandEnabled('Undo')) |
30 'Undo should not be enabled after the location changed.'); | 41 log("Success"); |
31 }, 'Checks after the subframe has navigated'); | 42 else |
| 43 log("Failure, Undo was still enabled after the location changed (but at
least we didn't crash!)"); |
| 44 |
| 45 if (window.testRunner) |
| 46 testRunner.notifyDone(); |
32 } | 47 } |
33 | 48 |
34 function runTest() { | 49 function runTest() { |
35 if (window.location.toString().indexOf("?part2") == -1) { | 50 if (window.location.toString().indexOf("?part2") == -1) { |
36 part1(); | 51 part1(); |
37 } else { | 52 } else { |
38 part2(); | 53 part2(); |
39 } | 54 } |
40 } | 55 } |
| 56 |
| 57 if (window.testRunner) { |
| 58 testRunner.waitUntilDone(); |
| 59 testRunner.dumpAsText(); |
| 60 } |
| 61 |
41 </script> | 62 </script> |
42 | 63 |
43 <body onload="runTest()"> | 64 <body onload="runTest()"> |
44 <iframe name="iframe" src="../resources/contenteditable-iframe-src.html"></ifram
e> | 65 <iframe name="iframe" src="../resources/contenteditable-iframe-src.html"></ifram
e> |
45 <div id="log"></div> | 66 <ul id="console"></ul> |
46 </body> | 67 </body> |
OLD | NEW |