Skip to content

Commit c645638

Browse files
committed
Adjust image smoothing tests for IE.
1 parent a9f1df5 commit c645638

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

test/test.js

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,20 @@
6060
var imageUrlJPEG = 'data:image/jpeg;base64,' + b64DataJPEG
6161
var blobJPEG = browser.canCreateBlob && window.dataURLtoBlob(imageUrlJPEG)
6262

63+
;(function imageSmoothingTest($) {
64+
var canvas = document.createElement('canvas')
65+
if (!canvas.getContext) return
66+
var ctx = canvas.getContext('2d')
67+
if (ctx.msImageSmoothingEnabled) {
68+
$.imageSmoothingEnabled = ctx.msImageSmoothingEnabled
69+
$.imageSmoothingEnabledKey = 'msImageSmoothingEnabled'
70+
} else {
71+
$.imageSmoothingEnabled = ctx.imageSmoothingEnabled
72+
$.imageSmoothingEnabledKey = 'imageSmoothingEnabled'
73+
}
74+
$.imageSmoothingQuality = ctx.imageSmoothingQuality
75+
})(browser)
76+
6377
// Test if the browser is using exact image data when transforming the canvas.
6478
// Both Internet Explorer and Edge Legacy have off-by-one changes to color and
6579
// transparency values when flipping images.
@@ -480,9 +494,7 @@
480494
})
481495

482496
describe('image smoothing', function () {
483-
if (
484-
!document.createElement('canvas').getContext('2d').imageSmoothingEnabled
485-
) {
497+
if (!browser.imageSmoothingEnabled) {
486498
return
487499
}
488500

@@ -492,7 +504,9 @@
492504
blobGIF,
493505
function (img) {
494506
expect(img.width).to.equal(120)
495-
expect(img.getContext('2d').imageSmoothingEnabled).to.equal(true)
507+
expect(
508+
img.getContext('2d')[browser.imageSmoothingEnabledKey]
509+
).to.equal(true)
496510
done()
497511
},
498512
{ minWidth: 120, canvas: true }
@@ -506,18 +520,17 @@
506520
blobGIF,
507521
function (img) {
508522
expect(img.width).to.equal(120)
509-
expect(img.getContext('2d').imageSmoothingEnabled).to.equal(false)
523+
expect(
524+
img.getContext('2d')[browser.imageSmoothingEnabledKey]
525+
).to.equal(false)
510526
done()
511527
},
512528
{ minWidth: 120, canvas: true, imageSmoothingEnabled: false }
513529
)
514530
).to.be.ok
515531
})
516532

517-
if (
518-
document.createElement('canvas').getContext('2d')
519-
.imageSmoothingQuality !== 'low'
520-
) {
533+
if (browser.imageSmoothingQuality !== 'low') {
521534
return
522535
}
523536

0 commit comments

Comments
 (0)