summaryrefslogtreecommitdiffstats
path: root/test/wpt/tests/mimesniff/media/media-sniff.window.js
blob: 8e9bf9a27e829a00a70d227b5480b995726e3b60 (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
29
30
31
32
const tests = {
  "vectors": [
    "mp3-raw.mp3",
    "mp3-with-id3.mp3",
    "flac.flac",
    "ogg.ogg",
    "mp4.mp4",
    "wav.wav",
    "webm.webm"
  ],
  "contentTypes": [
    "",
    "bogus/mime",
    "application/octet-stream",
    "text/html",
    "audio/ogg; codec=vorbis",
    "application/pdf"
  ]
};

tests.vectors.forEach(vector => {
  tests.contentTypes.forEach(type => {
    async_test(t => {
      const element = document.createElement("audio");
      element.src = "resources/" + vector + "?pipe=header(Content-Type,"+type+")"

      element.addEventListener("error", t.unreached_func("No error expected frorm the HTMLMediaElement"));
      element.addEventListener("loadedmetadata", t.step_func_done());
      element.load();
    }, vector + " loads when served with Content-Type " + type);
  });
});