tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_ckeditor4_compat_hack.html (1428B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <meta charset="utf-8">
      5  <title>Test that for the specific CKEditor 4 iframe, we get an async initial about:blank load</title>
      6  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      7  <link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
      8  <script>
      9 
     10 async function base_test(options = {}) {
     11  const {
     12    cls = "cke_wysiwyg_frame",
     13    src = "",
     14    name = "CKEDITOR",
     15    version = "4.15.0",
     16    asyncLoad = true
     17  } = options;
     18 
     19  window[name] = { version };
     20 
     21  const iframe = document.createElement("iframe");
     22  iframe.src = src;
     23  iframe.classList.add(cls);
     24  let loadCnt = 0;
     25  iframe.addEventListener("load", () => ++loadCnt );
     26  document.body.append(iframe);
     27 
     28  is(loadCnt, asyncLoad ? 0 : 1, "CKEditor frame got expected amount of sync loads")
     29 
     30  if (loadCnt == 0 && asyncLoad) {
     31    await new Promise(resolve => iframe.addEventListener("load", resolve, { once: true }));
     32    ok(true, "CKEditor received an async load");
     33  }
     34 
     35  iframe.remove();
     36  window[name] = undefined;
     37 }
     38 
     39 add_task(async function test_sanity_sync_load() {
     40  await base_test({ name: "NOT_CKEDITOR", asyncLoad: false });
     41 });
     42 
     43 add_task(async function test_ckeditor() {
     44  await base_test();
     45 });
     46 
     47 add_task(async function test_jeditor() {
     48  await base_test({ name: "JEDITOR" });
     49 });
     50 
     51  </script>
     52 </head>
     53 <body>
     54 <p id="display"></p>
     55 <div id="content" style="display: none"></div>
     56 <pre id="test"></pre>
     57 </body>
     58 </html>