summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/contentType.window.js
blob: 5a912038749f9410aefd44e1614027cc5f650359 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// META: script=/common/media.js

const videoURL = getVideoURI("/images/pattern"),
      videoMIMEType = getMediaContentType(videoURL);

[
  [videoURL, videoMIMEType, "video"],
  ["/images/red.png", "image/png", "image"],
  ["/common/text-plain.txt", "text/plain", "text"],
  ["/common/blank.html", "text/html", "HTML"]
].forEach(val => {
  async_test(t => {
    const frame = document.body.appendChild(document.createElement("iframe"));
    t.add_cleanup(() => frame.remove());
    frame.src = val[0];
    frame.onload = t.step_func_done(() => {
      assert_equals(frame.contentDocument.contentType, val[1]);
      frame.contentDocument.write("<b>Heya</b>");
      assert_equals(frame.contentDocument.body.firstChild.localName, "b");
      assert_equals(frame.contentDocument.body.firstChild.textContent, "Heya");
      assert_equals(frame.contentDocument.contentType, val[1]);

      // Make sure a load event is fired across browsers
      // https://github.com/web-platform-tests/wpt/pull/10239
      frame.contentDocument.close();
    });
  }, "document.write(): " + val[2] + " document");
});