summaryrefslogtreecommitdiffstats
path: root/devtools/client/shared/source-map-loader/test/browser/browser_getContentType.js
blob: 5ac402951cd0265342dcc522b191b17e158641af (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
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

// Cover the automatic mapping of content type based on file extension

const {
  getContentType,
  contentMapForTesting,
} = require("resource://devtools/client/shared/source-map-loader/utils/index.js");

add_task(async () => {
  for (const ext in contentMapForTesting) {
    is(
      getContentType(`whatever.${ext}`),
      contentMapForTesting[ext],
      `${ext} file extension is correctly mapping the expected content type`
    );
  }
  is(
    getContentType(`whateverjs`),
    "text/plain",
    `A valid extension in file name doesn't cause a special content type mapping`
  );

  is(
    getContentType("whatever.platypus"),
    "text/plain",
    "Test unknown extension defaults to text plain"
  );
});