]> git.proxmox.com Git - mirror_novnc.git/blobdiff - tests/assertions.js
Remove many small, obsolete, old browser hacks
[mirror_novnc.git] / tests / assertions.js
index 05957c083614bd44a6a5b0454fd8e7bcc5a0047b..c33c81ec531ebdbad558252ee6a72c5caeb26b35 100644 (file)
@@ -1,16 +1,17 @@
 // noVNC specific assertions
 chai.use(function (_chai, utils) {
-    _chai.Assertion.addMethod('displayed', function (targetData) {
+    function _equal(a, b) {
+        return a === b;
+    }
+    _chai.Assertion.addMethod('displayed', function (targetData, cmp=_equal) {
         const obj = this._obj;
         const ctx = obj._target.getContext('2d');
-        const dataCl = ctx.getImageData(0, 0, obj._target.width, obj._target.height).data;
-        // NB(directxman12): PhantomJS 1.x doesn't implement Uint8ClampedArray, so work around that
-        const data = new Uint8Array(dataCl);
-        const len = dataCl.length;
+        const data = ctx.getImageData(0, 0, obj._target.width, obj._target.height).data;
+        const len = data.length;
         new chai.Assertion(len).to.be.equal(targetData.length, "unexpected display size");
         let same = true;
         for (let i = 0; i < len; i++) {
-            if (data[i] != targetData[i]) {
+            if (!cmp(data[i], targetData[i])) {
                 same = false;
                 break;
             }