|
60 | 60 | var imageUrlJPEG = 'data:image/jpeg;base64,' + b64DataJPEG |
61 | 61 | var blobJPEG = browser.canCreateBlob && window.dataURLtoBlob(imageUrlJPEG) |
62 | 62 |
|
| 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 | + |
63 | 77 | // Test if the browser is using exact image data when transforming the canvas. |
64 | 78 | // Both Internet Explorer and Edge Legacy have off-by-one changes to color and |
65 | 79 | // transparency values when flipping images. |
|
480 | 494 | }) |
481 | 495 |
|
482 | 496 | describe('image smoothing', function () { |
483 | | - if ( |
484 | | - !document.createElement('canvas').getContext('2d').imageSmoothingEnabled |
485 | | - ) { |
| 497 | + if (!browser.imageSmoothingEnabled) { |
486 | 498 | return |
487 | 499 | } |
488 | 500 |
|
|
492 | 504 | blobGIF, |
493 | 505 | function (img) { |
494 | 506 | 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) |
496 | 510 | done() |
497 | 511 | }, |
498 | 512 | { minWidth: 120, canvas: true } |
|
506 | 520 | blobGIF, |
507 | 521 | function (img) { |
508 | 522 | 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) |
510 | 526 | done() |
511 | 527 | }, |
512 | 528 | { minWidth: 120, canvas: true, imageSmoothingEnabled: false } |
513 | 529 | ) |
514 | 530 | ).to.be.ok |
515 | 531 | }) |
516 | 532 |
|
517 | | - if ( |
518 | | - document.createElement('canvas').getContext('2d') |
519 | | - .imageSmoothingQuality !== 'low' |
520 | | - ) { |
| 533 | + if (browser.imageSmoothingQuality !== 'low') { |
521 | 534 | return |
522 | 535 | } |
523 | 536 |
|
|
0 commit comments