legacy-edit-command.html (3528B)
1 <!doctype html> 2 <html> 3 <meta charset=utf-8> 4 <meta name="variant" content="?command=increaseFontSize"> 5 <meta name="variant" content="?command=decreaseFontSize"> 6 <meta name="variant" content="?command=getHTML"> 7 <meta name="variant" content="?command=insertBrOrReturn¶m=true"> 8 <meta name="variant" content="?command=insertBrOrReturn¶m=false"> 9 <meta name="variant" content="?command=heading¶m=h1"> 10 <meta name="variant" content="?command=heading¶m=h2"> 11 <meta name="variant" content="?command=heading¶m=h3"> 12 <meta name="variant" content="?command=heading¶m=h4"> 13 <meta name="variant" content="?command=heading¶m=h5"> 14 <meta name="variant" content="?command=heading¶m=h6"> 15 <meta name="variant" content="?command=contentReadOnly¶m=true"> 16 <meta name="variant" content="?command=contentReadOnly¶m=false"> 17 <meta name="variant" content="?command=readonly¶m=true"> 18 <meta name="variant" content="?command=readonly¶m=false"> 19 <title>Test legacy commands won't work</title> 20 <script src=/resources/testharness.js></script> 21 <script src=/resources/testharnessreport.js></script> 22 </head> 23 <body contenteditable></body> 24 <script> 25 "use strict"; 26 27 const testParams = new URLSearchParams(location.search.substring(1)); 28 const command = testParams.get("command"); 29 const param = testParams.has("param") ? testParams.get("param") : undefined; 30 31 const editor = document.body; 32 33 promise_test(async () => { 34 await new Promise(resolve => addEventListener("load", resolve, {once: true})); 35 }, "Wait for load..."); 36 37 promise_test(async () => { 38 function reset() { 39 editor.innerHTML = "<p>abc</p>"; 40 editor.focus(); 41 getSelection().setBaseAndExtent( 42 editor.querySelector("p").firstChild, 43 1, 44 editor.querySelector("p").firstChild, 45 2 46 ); 47 } 48 test(() => { 49 reset(); 50 let inputEvents = []; 51 function onInput(event) { 52 inputEvents.push(event); 53 } 54 editor.addEventListener("input", onInput); 55 try { 56 assert_equals( 57 document.execCommand(command, false, param), 58 false, 59 "result should be false" 60 ); 61 assert_equals( 62 editor.outerHTML, 63 "<body contenteditable=\"\"><p>abc</p></body>", 64 "editable content shouldn't be modified" 65 ); 66 assert_equals( 67 inputEvents.length, 68 0, 69 "no input events should be fired" 70 ); 71 } finally { 72 editor.removeEventListener("input", onInput); 73 } 74 }, `execCommand("${command}", false, ${param === undefined ? "undefined" : `"${param}"`})`); 75 test(() => { 76 reset(); 77 assert_equals( 78 document.queryCommandState(command), 79 false, 80 "result should be false" 81 ); 82 }, `queryCommandState("${command}")`); 83 test(() => { 84 reset(); 85 assert_equals( 86 document.queryCommandEnabled(command), 87 false, 88 "result should be false" 89 ); 90 }, `queryCommandEnabled("${command}")`); 91 test(() => { 92 reset(); 93 assert_equals( 94 document.queryCommandIndeterm(command), 95 false, 96 "result should be false" 97 ); 98 }, `queryCommandIndeterm("${command}")`); 99 test(() => { 100 reset(); 101 assert_equals( 102 document.queryCommandValue(command), 103 "", 104 "result should be empty string" 105 ); 106 }, `queryCommandValue("${command}")`); 107 test(() => { 108 reset(); 109 assert_equals( 110 document.queryCommandSupported(command), 111 false, 112 "result should be false" 113 ); 114 }, `queryCommandSupported("${command}")`); 115 }, `command: "${command}", param: "${param}"`); 116 </script> 117 </html>