yzt
2023-05-26 2f70f6727314edd84d8ec2bfe3ce832803f1ea77
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
import { FeatureDetection } from "../../Source/Cesium.js";
 
describe("Core/FeatureDetection", function () {
  //generally, these tests just make sure the function runs, the test can't expect a value of true or false
  it("detects fullscreen support", function () {
    var supportsFullscreen = FeatureDetection.supportsFullscreen();
    expect(typeof supportsFullscreen).toEqual("boolean");
  });
 
  it("detects web worker support", function () {
    var supportsWebWorkers = FeatureDetection.supportsWebWorkers();
    expect(typeof supportsWebWorkers).toEqual("boolean");
  });
 
  it("detects typed array support", function () {
    var supportsTypedArrays = FeatureDetection.supportsTypedArrays();
    expect(typeof supportsTypedArrays).toEqual("boolean");
  });
 
  it("detects BigInt64Array support", function () {
    var supportsBigInt64Array = FeatureDetection.supportsBigInt64Array();
    expect(typeof supportsBigInt64Array).toEqual("boolean");
  });
 
  it("detects BigUint64Array support", function () {
    var supportsBigUint64Array = FeatureDetection.supportsBigUint64Array();
    expect(typeof supportsBigUint64Array).toEqual("boolean");
  });
 
  it("detects BigInt support", function () {
    var supportsBigInt = FeatureDetection.supportsBigInt();
    expect(typeof supportsBigInt).toEqual("boolean");
  });
 
  it("detects web assembly support", function () {
    var supportsWebAssembly = FeatureDetection.supportsWebAssembly();
    expect(typeof supportsWebAssembly).toEqual("boolean");
  });
 
  function checkVersionArray(array) {
    expect(Array.isArray(array)).toEqual(true);
    array.forEach(function (d) {
      expect(typeof d).toEqual("number");
    });
  }
 
  it("detects Chrome", function () {
    var isChrome = FeatureDetection.isChrome();
    expect(typeof isChrome).toEqual("boolean");
 
    if (isChrome) {
      var chromeVersion = FeatureDetection.chromeVersion();
      checkVersionArray(chromeVersion);
 
      console.log("detected Chrome " + chromeVersion.join("."));
    }
  });
 
  it("detects Safari", function () {
    var isSafari = FeatureDetection.isSafari();
    expect(typeof isSafari).toEqual("boolean");
 
    if (isSafari) {
      var safariVersion = FeatureDetection.safariVersion();
      checkVersionArray(safariVersion);
 
      console.log("detected Safari " + safariVersion.join("."));
    }
  });
 
  it("detects Webkit", function () {
    var isWebkit = FeatureDetection.isWebkit();
    expect(typeof isWebkit).toEqual("boolean");
 
    if (isWebkit) {
      var webkitVersion = FeatureDetection.webkitVersion();
      checkVersionArray(webkitVersion);
      expect(typeof webkitVersion.isNightly).toEqual("boolean");
 
      console.log(
        "detected Webkit " +
          webkitVersion.join(".") +
          (webkitVersion.isNightly ? " (Nightly)" : "")
      );
    }
  });
 
  it("detects Internet Explorer", function () {
    var isInternetExplorer = FeatureDetection.isInternetExplorer();
    expect(typeof isInternetExplorer).toEqual("boolean");
 
    if (isInternetExplorer) {
      var internetExplorerVersion = FeatureDetection.internetExplorerVersion();
      checkVersionArray(internetExplorerVersion);
 
      console.log(
        "detected Internet Explorer " + internetExplorerVersion.join(".")
      );
    }
  });
 
  it("detects Edge", function () {
    var isEdge = FeatureDetection.isEdge();
    expect(typeof isEdge).toEqual("boolean");
 
    if (isEdge) {
      var edgeVersion = FeatureDetection.edgeVersion();
      checkVersionArray(edgeVersion);
 
      console.log("detected Edge " + edgeVersion.join("."));
    }
  });
 
  it("detects Firefox", function () {
    var isFirefox = FeatureDetection.isFirefox();
    expect(typeof isFirefox).toEqual("boolean");
 
    if (isFirefox) {
      var firefoxVersion = FeatureDetection.firefoxVersion();
 
      checkVersionArray(firefoxVersion);
 
      console.log("detected Firefox " + firefoxVersion.join("."));
    }
  });
 
  it("detects imageRendering support", function () {
    var supportsImageRenderingPixelated = FeatureDetection.supportsImageRenderingPixelated();
    expect(typeof supportsImageRenderingPixelated).toEqual("boolean");
    if (supportsImageRenderingPixelated) {
      expect(FeatureDetection.imageRenderingValue()).toBeDefined();
    } else {
      expect(FeatureDetection.imageRenderingValue()).not.toBeDefined();
    }
  });
 
  it("supportWebP throws when it has not been initialized", function () {
    FeatureDetection.supportsWebP._promise = undefined;
    FeatureDetection.supportsWebP._result = undefined;
    expect(function () {
      FeatureDetection.supportsWebP();
    }).toThrowDeveloperError();
  });
 
  it("detects WebP support", function () {
    FeatureDetection.supportsWebP._promise = undefined;
    FeatureDetection.supportsWebP._result = undefined;
 
    return FeatureDetection.supportsWebP
      .initialize()
      .then(function (supportsWebP) {
        expect(typeof supportsWebP).toEqual("boolean");
        expect(FeatureDetection.supportsWebP()).toEqual(supportsWebP);
      });
  });
});