aboutsummaryrefslogtreecommitdiffstats
path: root/library/cropperjs/test/options/checkCrossOrigin.js
blob: 86fde8f6f236e66d4b2f95a23bc340c98620edf6 (plain) (blame)
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
QUnit.test('options#checkCrossOrigin: true', function (assert) {
  var done = assert.async();
  var util = window.Util;
  var image = util.createImage({
        src: 'https://fengyuanchen.github.io/cropperjs/images/picture.jpg'
      });

  assert.expect(2);

  return new Cropper(image, {
    // checkCrossOrigin: true,

    ready: function () {
      var cropper = this.cropper;

      assert.strictEqual(cropper.image.crossOrigin, 'anonymous');
      assert.ok(cropper.image.src.indexOf('timestamp') >= 0);

      done();
    }
  });
});

QUnit.test('options#checkCrossOrigin: false', function (assert) {
  var done = assert.async();
  var util = window.Util;
  var image = util.createImage({
        src: 'https://fengyuanchen.github.io/cropperjs/images/picture.jpg'
      });

  assert.expect(2);

  return new Cropper(image, {
    checkCrossOrigin: false,

    ready: function () {
      var cropper = this.cropper;

      assert.notStrictEqual(cropper.image.crossOrigin, 'anonymous');
      assert.ok(cropper.image.src.indexOf('timestamp') < 0);

      done();
    }
  });
});

QUnit.test('options#checkCrossOrigin: exists crossOrigin attribute', function (assert) {
  var done = assert.async();
  var util = window.Util;
  var image = util.createImage({
        src: 'https://fengyuanchen.github.io/cropperjs/images/picture.jpg',
        crossOrigin: 'anonymous'
      });

  assert.expect(2);

  return new Cropper(image, {
    ready: function () {
      var cropper = this.cropper;

      assert.strictEqual(cropper.image.crossOrigin, 'anonymous');
      assert.ok(cropper.image.src.indexOf('timestamp') < 0);

      done();
    }
  });
});