Ticket #8226: ie_destroy_bug.2.html

File ie_destroy_bug.2.html, 2.2 KB (added by Alfonso Martínez de Lizarrondo, 13 years ago)

Updated test

Line 
1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2<html xmlns="http://www.w3.org/1999/xhtml">
3  <head>
4    <title>destroy test</title>
5
6        <script type="text/javascript" src="../ckeditor_source.js"></script>
7  </head>
8  <body>
9    <div>
10      <a href="javascript:;" onclick="runTests()">Start the tests</a>
11    </div>
12    <hr />
13
14    <div id="errors1">
15      <b>Errors on #1:</b><br />
16    </div>
17    <hr />
18
19    <div id="errors2">
20      <b>Errors on #2:</b><br />
21    </div>
22    <hr />
23
24        <form id="form1">
25      <textarea id="editor1">CKEditor #1</textarea>
26    </form>
27
28    <form id="form2">
29      <textarea id="editor2">CKEditor #2</textarea>
30    </form>
31
32    <script type="text/javascript">
33      function runTests() {
34        // Shouldn't create errors.
35        createCKEditor(1);
36        destroyCKEditor(1);
37
38        // If the editor instance isn't a descendant of document.body, things break.
39        createCKEditor(2);
40        destroyCKEditor(2, function() {
41          var new_el = document.createElement('div');
42          new_el.appendChild(document.getElementById('form2'));
43        });
44
45          };
46
47      function createCKEditor(editor_id) {
48        window['ckInstanceReady'+editor_id] = false;
49        CKEDITOR.on('instanceReady', function(e) {
50          window['ckInstanceReady'+editor_id] = true;
51        });
52        CKEDITOR.replace(document.getElementById('editor'+editor_id));
53      };
54
55      function destroyCKEditor(editor_id, when_ready) {
56        window['ckInstanceInterval'+editor_id] = setInterval(function() {
57          if(window['ckInstanceReady'+editor_id]) {
58            clearInterval(window['ckInstanceInterval'+editor_id]);
59
60            if(typeof when_ready == 'function')
61              when_ready();
62
63            var ckinstance = CKEDITOR.instances['editor'+editor_id],
64              errors = document.getElementById('errors'+editor_id);
65
66            try {
67              ckinstance.destroy();
68              errors.innerHTML += 'No Errors';
69            } catch(err) {
70              //throw(err);
71              window.errors = err;
72              errors.innerHTML += err.message + '<br />' + err.stack;
73            }
74          }
75        }, 500);
76      }
77
78    </script>
79
80  </body>
81</html>
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy