tor-browser

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

parseHTMLUnsafe-url-tests.js (1018B)


      1 const loadPromise = new Promise(resolve => { window.resolveLoadPromise = resolve; });
      2 
      3 function assertURL(doc) {
      4  assert_equals(doc.URL, "about:blank", "document.URL");
      5  assert_equals(doc.documentURI, "about:blank", "document.documentURI");
      6  assert_equals(doc.baseURI, "about:blank", "document.baseURI");
      7 }
      8 
      9 const inputs = {
     10  valid: "<html></html>",
     11  "invalid XML": `<span x:test="testing">1</span>`
     12 };
     13 
     14 for (const [inputName, input] of Object.entries(inputs)) {
     15  test(() => {
     16    const doc = Document.parseHTMLUnsafe(input);
     17 
     18    assertURL(doc);
     19  }, `${inputName}: created normally`);
     20 
     21  promise_test(async () => {
     22    await loadPromise;
     23 
     24    const doc = frames[0].Document.parseHTMLUnsafe(input);
     25 
     26    assertURL(doc);
     27  }, `${inputName}: created using another iframe's parseHTMLUnsafe from this frame`);
     28 
     29  promise_test(async () => {
     30    await loadPromise;
     31 
     32    const doc = frames[0].doParse(input);
     33 
     34    assertURL(doc);
     35  }, `${inputName}: created using another iframe's parseHTMLUnsafe from that frame`);
     36 }