ember-source 2.17.0.beta.6 → 2.17.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fc76f1256f89281f1101a8b6cbe18ce6aa8d808acc7ad972f464ee2bd60868e4
4
- data.tar.gz: 435fc50d189de1e04e3ac470f1d702636b0e7cbf6c2fec895c59537445b47e7d
3
+ metadata.gz: 95e938d86ca0a249b756a1455bc026e00250e745e1e5bbdb08a48f8e2452b87b
4
+ data.tar.gz: c9877fca81d912f7eeb3a34eae1639feba4c2e5f4366ed92f3741a16ad789555
5
5
  SHA512:
6
- metadata.gz: bfdfa4749ec734d52da0084ee4b7e8a409706159a30c02dc87ea3b76f1fe3ce7c9e9a0d2726e8ce6ab548c7c6b75617f6753d7c324c1d9caa2518bd4a8e97c0e
7
- data.tar.gz: '09287926dee6a4217d256fb8d877419c74a8e8945f4082adbcd59c4723cd5c16db6ac5ddc6ece5bd3e22f8dc01409eafce011902cae2816e6302f07fdf742846'
6
+ metadata.gz: 8b0dd35d73dc5487eda6b3ddf2bfada306126dae671903b5093febf624d65597d919018390f012dd31fa3f3f8a46f1e1a44109d92eb1ff886bc7ac465bb813f5
7
+ data.tar.gz: 0f734ca572a886be16a720a9ddc6748522899796a2fe7647704fccdd93f9ff9cbbcb274f879781f06dfcd94d3971f71533839231888c3b4478a57383cc96071b
@@ -6,7 +6,7 @@
6
6
  * Portions Copyright 2008-2011 Apple Inc. All rights reserved.
7
7
  * @license Licensed under MIT license
8
8
  * See https://raw.github.com/emberjs/ember.js/master/LICENSE
9
- * @version 2.17.0-beta.6
9
+ * @version 2.17.0
10
10
  */
11
11
 
12
12
  var enifed, requireModule, Ember;
@@ -5531,22 +5531,10 @@ enifed('ember-metal', ['exports', 'ember-environment', 'ember-utils', 'ember-deb
5531
5531
  cache = {};
5532
5532
  }
5533
5533
 
5534
- // To maintain stacktrace consistency across browsers
5535
- var getStack = function (error) {
5536
- var stack = error.stack;
5537
- var message = error.message;
5538
-
5539
- if (stack && stack.indexOf(message) === -1) {
5540
- stack = message + '\n' + stack;
5541
- }
5542
-
5543
- return stack;
5544
- };
5545
-
5546
5534
  var onerror = void 0;
5547
5535
  var onErrorTarget = {
5548
5536
  get onerror() {
5549
- return dispatchOverride || onerror;
5537
+ return onerror;
5550
5538
  }
5551
5539
  };
5552
5540
 
@@ -5560,14 +5548,6 @@ enifed('ember-metal', ['exports', 'ember-environment', 'ember-utils', 'ember-deb
5560
5548
  }
5561
5549
 
5562
5550
  var dispatchOverride = void 0;
5563
- // dispatch error
5564
- function dispatchError(error) {
5565
- if (dispatchOverride) {
5566
- dispatchOverride(error);
5567
- } else {
5568
- defaultDispatch(error);
5569
- }
5570
- }
5571
5551
 
5572
5552
  // allows testing adapter to override dispatch
5573
5553
  function getDispatchOverride() {
@@ -5577,17 +5557,6 @@ enifed('ember-metal', ['exports', 'ember-environment', 'ember-utils', 'ember-deb
5577
5557
  dispatchOverride = handler;
5578
5558
  }
5579
5559
 
5580
- function defaultDispatch(error) {
5581
- if (emberDebug.isTesting()) {
5582
- throw error;
5583
- }
5584
- if (onerror) {
5585
- onerror(error);
5586
- } else {
5587
- Logger.error(getStack(error));
5588
- }
5589
- }
5590
-
5591
5560
  /**
5592
5561
  @module @ember/utils
5593
5562
  */
@@ -8748,7 +8717,6 @@ enifed('ember-metal', ['exports', 'ember-environment', 'ember-utils', 'ember-deb
8748
8717
  exports.instrumentationUnsubscribe = unsubscribe;
8749
8718
  exports.getOnerror = getOnerror;
8750
8719
  exports.setOnerror = setOnerror;
8751
- exports.dispatchError = dispatchError;
8752
8720
  exports.setDispatchOverride = setDispatchOverride;
8753
8721
  exports.getDispatchOverride = getDispatchOverride;
8754
8722
  exports.META_DESC = META_DESC;
@@ -6,7 +6,7 @@
6
6
  * Portions Copyright 2008-2011 Apple Inc. All rights reserved.
7
7
  * @license Licensed under MIT license
8
8
  * See https://raw.github.com/emberjs/ember.js/master/LICENSE
9
- * @version 2.17.0-beta.6
9
+ * @version 2.17.0
10
10
  */
11
11
 
12
12
  var enifed, requireModule, Ember;
@@ -5146,13 +5146,10 @@ enifed('backburner', ['exports'], function (exports) {
5146
5146
  }
5147
5147
  }
5148
5148
  }
5149
- var onError = getOnError(this.options);
5150
- if (onError) {
5151
- try {
5152
- return method.apply(target, args);
5153
- } catch (error) {
5154
- onError(error);
5155
- }
5149
+ if (length === 1) {
5150
+ return method();
5151
+ } else if (length === 2) {
5152
+ return method.call(target);
5156
5153
  } else {
5157
5154
  return method.apply(target, args);
5158
5155
  }
@@ -11718,22 +11715,10 @@ enifed('ember-metal', ['exports', 'ember-environment', 'ember-utils', 'ember-deb
11718
11715
  */
11719
11716
 
11720
11717
 
11721
- // To maintain stacktrace consistency across browsers
11722
- var getStack = function (error) {
11723
- var stack = error.stack;
11724
- var message = error.message;
11725
-
11726
- if (stack && stack.indexOf(message) === -1) {
11727
- stack = message + '\n' + stack;
11728
- }
11729
-
11730
- return stack;
11731
- };
11732
-
11733
11718
  var onerror = void 0;
11734
11719
  var onErrorTarget = {
11735
11720
  get onerror() {
11736
- return dispatchOverride || onerror;
11721
+ return onerror;
11737
11722
  }
11738
11723
  };
11739
11724
 
@@ -11743,23 +11728,10 @@ enifed('ember-metal', ['exports', 'ember-environment', 'ember-utils', 'ember-deb
11743
11728
 
11744
11729
 
11745
11730
  var dispatchOverride = void 0;
11746
- // dispatch error
11747
-
11748
11731
 
11749
11732
  // allows testing adapter to override dispatch
11750
11733
 
11751
11734
 
11752
- function defaultDispatch(error) {
11753
- if (emberDebug.isTesting()) {
11754
- throw error;
11755
- }
11756
- if (onerror) {
11757
- onerror(error);
11758
- } else {
11759
- Logger.error(getStack(error));
11760
- }
11761
- }
11762
-
11763
11735
  /**
11764
11736
  @module @ember/utils
11765
11737
  */
@@ -14915,13 +14887,6 @@ enifed('ember-metal', ['exports', 'ember-environment', 'ember-utils', 'ember-deb
14915
14887
  exports.setOnerror = function (handler) {
14916
14888
  onerror = handler;
14917
14889
  };
14918
- exports.dispatchError = function (error) {
14919
- if (dispatchOverride) {
14920
- dispatchOverride(error);
14921
- } else {
14922
- defaultDispatch(error);
14923
- }
14924
- };
14925
14890
  exports.setDispatchOverride = function (handler) {
14926
14891
  dispatchOverride = handler;
14927
14892
  };
@@ -17355,7 +17320,7 @@ enifed('ember/features', ['exports', 'ember-environment', 'ember-utils'], functi
17355
17320
  enifed("ember/version", ["exports"], function (exports) {
17356
17321
  "use strict";
17357
17322
 
17358
- exports.default = "2.17.0-beta.6";
17323
+ exports.default = "2.17.0";
17359
17324
  });
17360
17325
  enifed("handlebars", ["exports"], function (exports) {
17361
17326
  "use strict";
@@ -6,7 +6,7 @@
6
6
  * Portions Copyright 2008-2011 Apple Inc. All rights reserved.
7
7
  * @license Licensed under MIT license
8
8
  * See https://raw.github.com/emberjs/ember.js/master/LICENSE
9
- * @version 2.17.0-beta.6
9
+ * @version 2.17.0
10
10
  */
11
11
 
12
12
  var enifed, requireModule, Ember;
@@ -2113,7 +2113,7 @@ enifed('ember-testing/test/adapter', ['exports', 'ember-console', 'ember-metal']
2113
2113
 
2114
2114
  function setAdapter(value) {
2115
2115
  adapter = value;
2116
- if (value) {
2116
+ if (value && typeof value.exception === 'function') {
2117
2117
  (0, _emberMetal.setDispatchOverride)(adapterDispatch);
2118
2118
  } else {
2119
2119
  (0, _emberMetal.setDispatchOverride)(null);
@@ -6,7 +6,7 @@
6
6
  * Portions Copyright 2008-2011 Apple Inc. All rights reserved.
7
7
  * @license Licensed under MIT license
8
8
  * See https://raw.github.com/emberjs/ember.js/master/LICENSE
9
- * @version 2.17.0-beta.6
9
+ * @version 2.17.0
10
10
  */
11
11
 
12
12
  var enifed, requireModule, Ember;
@@ -50642,6 +50642,24 @@ enifed('ember-runtime/tests/computed/reduce_computed_macros_test', ['ember-metal
50642
50642
  deepEqual(obj.get('filtered'), [20, 22, 24], 'computed array is updated when array is changed');
50643
50643
  });
50644
50644
 
50645
+ QUnit.test('it updates properly on @each with {} dependencies', function () {
50646
+ var item = _object.default.create({ prop: true });
50647
+
50648
+ obj = _object.default.extend({
50649
+ filtered: (0, _reduce_computed_macros.filter)('items.@each.{prop}', function (item, index) {
50650
+ return item.get('prop') === true;
50651
+ })
50652
+ }).create({
50653
+ items: (0, _native_array.A)([item])
50654
+ });
50655
+
50656
+ deepEqual(obj.get('filtered'), [item]);
50657
+
50658
+ item.set('prop', false);
50659
+
50660
+ deepEqual(obj.get('filtered'), []);
50661
+ });
50662
+
50645
50663
  QUnit.module('filterBy', {
50646
50664
  setup: function () {
50647
50665
  obj = _object.default.extend({
@@ -50944,7 +50962,7 @@ enifed('ember-runtime/tests/computed/reduce_computed_macros_test', ['ember-metal
50944
50962
  array: (0, _native_array.A)([1, 2, 3, 4, 5, 6, 7]),
50945
50963
  array2: (0, _native_array.A)([3, 4, 5])
50946
50964
  });
50947
- }, /Ember\.computed\.setDiff requires exactly two dependent arrays/, 'setDiff requires two dependent arrays');
50965
+ }, /\`Ember\.computed\.setDiff\` requires exactly two dependent arrays/, 'setDiff requires two dependent arrays');
50948
50966
 
50949
50967
  expectAssertion(function () {
50950
50968
  _object.default.extend({
@@ -50954,7 +50972,7 @@ enifed('ember-runtime/tests/computed/reduce_computed_macros_test', ['ember-metal
50954
50972
  array2: (0, _native_array.A)([3, 4, 5]),
50955
50973
  array3: (0, _native_array.A)([7])
50956
50974
  });
50957
- }, /Ember\.computed\.setDiff requires exactly two dependent arrays/, 'setDiff requires two dependent arrays');
50975
+ }, /\`Ember\.computed\.setDiff\` requires exactly two dependent arrays/, 'setDiff requires two dependent arrays');
50958
50976
  });
50959
50977
 
50960
50978
  QUnit.test('it has set-diff semantics', function () {
@@ -52516,12 +52534,10 @@ enifed('ember-runtime/tests/ext/rsvp_test', ['ember-metal', 'ember-runtime/ext/r
52516
52534
  try {
52517
52535
  (0, _emberMetal.run)(_rsvp.default, 'reject', 'foo');
52518
52536
  } catch (e) {
52519
- ok(false, 'should not throw');
52537
+ equal(e, 'foo', 'should throw with rejection message');
52520
52538
  } finally {
52521
52539
  (0, _emberDebug.setTesting)(wasEmberTesting);
52522
52540
  }
52523
-
52524
- ok(true);
52525
52541
  });
52526
52542
 
52527
52543
  QUnit.test('Can reject with no arguments', function (assert) {
@@ -64663,12 +64679,13 @@ QUnit.test('should pass ESLint', function(assert) {
64663
64679
  enifed('ember-testing/tests/adapters_test', ['ember-metal', 'ember-testing/test', 'ember-testing/adapters/adapter', 'ember-testing/adapters/qunit', 'ember-application'], function (_emberMetal, _test, _adapter, _qunit, _emberApplication) {
64664
64680
  'use strict';
64665
64681
 
64666
- var App, originalAdapter, originalQUnit;
64682
+ var App, originalAdapter, originalQUnit, originalWindowOnerror;
64667
64683
 
64668
64684
  QUnit.module('ember-testing Adapters', {
64669
64685
  setup: function () {
64670
64686
  originalAdapter = _test.default.adapter;
64671
64687
  originalQUnit = window.QUnit;
64688
+ originalWindowOnerror = window.onerror;
64672
64689
  },
64673
64690
  teardown: function () {
64674
64691
  if (App) {
@@ -64679,6 +64696,7 @@ enifed('ember-testing/tests/adapters_test', ['ember-metal', 'ember-testing/test'
64679
64696
 
64680
64697
  _test.default.adapter = originalAdapter;
64681
64698
  window.QUnit = originalQUnit;
64699
+ window.onerror = originalWindowOnerror;
64682
64700
  }
64683
64701
  });
64684
64702
 
@@ -64730,21 +64748,27 @@ enifed('ember-testing/tests/adapters_test', ['ember-metal', 'ember-testing/test'
64730
64748
  ok(!(_test.default.adapter instanceof _qunit.default));
64731
64749
  });
64732
64750
 
64733
- QUnit.test('With Ember.Test.adapter set, errors in Ember.run are caught', function () {
64751
+ QUnit.test('With Ember.Test.adapter set, errors in synchronous Ember.run are bubbled out', function (assert) {
64734
64752
  var thrown = new Error('Boom!');
64735
64753
 
64736
- var caught = void 0;
64754
+ var caughtInAdapter = void 0,
64755
+ caughtInCatch = void 0;
64737
64756
  _test.default.adapter = _qunit.default.create({
64738
64757
  exception: function (error) {
64739
- caught = error;
64758
+ caughtInAdapter = error;
64740
64759
  }
64741
64760
  });
64742
64761
 
64743
- (0, _emberMetal.run)(function () {
64744
- throw thrown;
64745
- });
64762
+ try {
64763
+ (0, _emberMetal.run)(function () {
64764
+ throw thrown;
64765
+ });
64766
+ } catch (e) {
64767
+ caughtInCatch = e;
64768
+ }
64746
64769
 
64747
- deepEqual(caught, thrown);
64770
+ assert.equal(caughtInAdapter, undefined, 'test adapter should never receive synchronous errors');
64771
+ assert.equal(caughtInCatch, thrown, 'a "normal" try/catch should catch errors in sync run');
64748
64772
  });
64749
64773
  });
64750
64774
  QUnit.module('ESLint | ember-testing/tests/adapters_test.js');
@@ -67638,91 +67662,546 @@ enifed('ember/tests/error_handler_test', ['ember', 'ember-metal'], function (_em
67638
67662
  var ADAPTER = _ember.default.Test && _ember.default.Test.adapter;
67639
67663
  var TESTING = _ember.default.testing;
67640
67664
 
67665
+ var WINDOW_ONERROR = void 0;
67666
+
67641
67667
  QUnit.module('error_handler', {
67668
+ setup: function () {
67669
+ // capturing this outside of module scope to ensure we grab
67670
+ // the test frameworks own window.onerror to reset it
67671
+ WINDOW_ONERROR = window.onerror;
67672
+ },
67642
67673
  teardown: function () {
67643
67674
  _ember.default.onerror = ONERROR;
67644
67675
  _ember.default.testing = TESTING;
67676
+ window.onerror = WINDOW_ONERROR;
67645
67677
  if (_ember.default.Test) {
67646
67678
  _ember.default.Test.adapter = ADAPTER;
67647
67679
  }
67648
67680
  }
67649
67681
  });
67650
67682
 
67651
- function runThatThrows(message) {
67683
+ function runThatThrowsSync() {
67684
+ var message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Error for testing error handling';
67685
+
67652
67686
  return (0, _emberMetal.run)(function () {
67653
67687
  throw new Error(message);
67654
67688
  });
67655
67689
  }
67656
67690
 
67657
- test('by default there is no onerror', function (assert) {
67658
- _ember.default.onerror = undefined;
67659
- assert.throws(runThatThrows, Error);
67660
- assert.equal(_ember.default.onerror, undefined);
67691
+ function runThatThrowsAsync() {
67692
+ var message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Error for testing error handling';
67693
+
67694
+ return _emberMetal.run.next(function () {
67695
+ throw new Error(message);
67696
+ });
67697
+ }
67698
+
67699
+ test('by default there is no onerror - sync run', function (assert) {
67700
+ assert.strictEqual(_ember.default.onerror, undefined, 'precond - there should be no Ember.onerror set by default');
67701
+ assert.throws(runThatThrowsSync, Error, 'errors thrown sync are catchable');
67661
67702
  });
67662
67703
 
67663
- test('when Ember.onerror is registered', function (assert) {
67704
+ test('when Ember.onerror (which rethrows) is registered - sync run', function (assert) {
67664
67705
  assert.expect(2);
67665
67706
  _ember.default.onerror = function (error) {
67666
67707
  assert.ok(true, 'onerror called');
67667
67708
  throw error;
67668
67709
  };
67669
- assert.throws(runThatThrows, Error);
67670
- // Ember.onerror = ONERROR;
67710
+ assert.throws(runThatThrowsSync, Error, 'error is thrown');
67711
+ });
67712
+
67713
+ test('when Ember.onerror (which does not rethrow) is registered - sync run', function (assert) {
67714
+ assert.expect(2);
67715
+ _ember.default.onerror = function (error) {
67716
+ assert.ok(true, 'onerror called');
67717
+ };
67718
+ runThatThrowsSync();
67719
+ assert.ok(true, 'no error was thrown, Ember.onerror can intercept errors');
67671
67720
  });
67672
67721
 
67673
67722
  if (true) {
67674
- test('when Ember.Test.adapter is registered', function (assert) {
67675
- assert.expect(2);
67723
+ test('when Ember.Test.adapter is registered and error is thrown - sync run', function (assert) {
67724
+ assert.expect(1);
67676
67725
 
67677
67726
  _ember.default.Test.adapter = {
67678
67727
  exception: function (error) {
67679
- assert.ok(true, 'adapter called');
67680
- throw error;
67728
+ assert.notOk(true, 'adapter is not called for errors thrown in sync run loops');
67681
67729
  }
67682
67730
  };
67683
67731
 
67684
- assert.throws(runThatThrows, Error);
67732
+ assert.throws(runThatThrowsSync, Error);
67685
67733
  });
67686
67734
 
67687
- test('when both Ember.onerror Ember.Test.adapter are registered', function (assert) {
67735
+ test('when both Ember.onerror (which rethrows) and Ember.Test.adapter are registered - sync run', function (assert) {
67688
67736
  assert.expect(2);
67689
67737
 
67690
- // takes precedence
67691
67738
  _ember.default.Test.adapter = {
67692
67739
  exception: function (error) {
67693
- assert.ok(true, 'adapter called');
67694
- throw error;
67740
+ assert.notOk(true, 'adapter is not called for errors thrown in sync run loops');
67695
67741
  }
67696
67742
  };
67697
67743
 
67698
67744
  _ember.default.onerror = function (error) {
67699
- assert.ok(false, 'onerror was NEVER called');
67745
+ assert.ok(true, 'onerror is called for sync errors even if Ember.Test.adapter is setup');
67700
67746
  throw error;
67701
67747
  };
67702
67748
 
67703
- assert.throws(runThatThrows, Error);
67749
+ assert.throws(runThatThrowsSync, Error, 'error is thrown');
67750
+ });
67751
+
67752
+ test('when both Ember.onerror (which does not rethrow) and Ember.Test.adapter are registered - sync run', function (assert) {
67753
+ assert.expect(2);
67754
+
67755
+ _ember.default.Test.adapter = {
67756
+ exception: function (error) {
67757
+ assert.notOk(true, 'adapter is not called for errors thrown in sync run loops');
67758
+ }
67759
+ };
67760
+
67761
+ _ember.default.onerror = function (error) {
67762
+ assert.ok(true, 'onerror is called for sync errors even if Ember.Test.adapter is setup');
67763
+ };
67764
+
67765
+ runThatThrowsSync();
67766
+ assert.ok(true, 'no error was thrown, Ember.onerror can intercept errors');
67767
+ });
67768
+
67769
+ QUnit.test('when Ember.Test.adapter is registered and error is thrown - async run', function (assert) {
67770
+ assert.expect(3);
67771
+ var done = assert.async();
67772
+
67773
+ var caughtInAdapter = void 0,
67774
+ caughtInCatch = void 0,
67775
+ caughtByWindowOnerror = void 0;
67776
+ _ember.default.Test.adapter = {
67777
+ exception: function (error) {
67778
+ caughtInAdapter = error;
67779
+ }
67780
+ };
67781
+
67782
+ window.onerror = function (message) {
67783
+ caughtByWindowOnerror = message;
67784
+ // prevent "bubbling" and therefore failing the test
67785
+ return true;
67786
+ };
67787
+
67788
+ try {
67789
+ runThatThrowsAsync();
67790
+ } catch (e) {
67791
+ caughtInCatch = e;
67792
+ }
67793
+
67794
+ setTimeout(function () {
67795
+ assert.equal(caughtInAdapter, undefined, 'test adapter should never catch errors in run loops');
67796
+ assert.equal(caughtInCatch, undefined, 'a "normal" try/catch should never catch errors in an async run');
67797
+
67798
+ assert.pushResult({
67799
+ result: /Error for testing error handling/.test(caughtByWindowOnerror),
67800
+ actual: caughtByWindowOnerror,
67801
+ expected: 'to include `Error for testing error handling`',
67802
+ message: 'error should bubble out to window.onerror, and therefore fail tests (due to QUnit implementing window.onerror)'
67803
+ });
67804
+
67805
+ done();
67806
+ }, 20);
67807
+ });
67808
+
67809
+ test('when both Ember.onerror and Ember.Test.adapter are registered - async run', function (assert) {
67810
+ assert.expect(1);
67811
+ var done = assert.async();
67812
+
67813
+ _ember.default.Test.adapter = {
67814
+ exception: function (error) {
67815
+ assert.notOk(true, 'Adapter.exception is not called for errors thrown in run.next');
67816
+ }
67817
+ };
67818
+
67819
+ _ember.default.onerror = function (error) {
67820
+ assert.ok(true, 'onerror is invoked for errors thrown in run.next/run.later');
67821
+ };
67822
+
67823
+ runThatThrowsAsync();
67824
+ setTimeout(done, 10);
67704
67825
  });
67705
67826
  }
67706
67827
 
67707
- QUnit.test('Ember.run does not swallow exceptions by default (Ember.testing = true)', function () {
67828
+ QUnit.test('does not swallow exceptions by default (Ember.testing = true, no Ember.onerror) - sync run', function (assert) {
67708
67829
  _ember.default.testing = true;
67830
+
67709
67831
  var error = new Error('the error');
67710
- throws(function () {
67832
+ assert.throws(function () {
67711
67833
  _ember.default.run(function () {
67712
67834
  throw error;
67713
67835
  });
67714
67836
  }, error);
67715
67837
  });
67716
67838
 
67717
- QUnit.test('Ember.run does not swallow exceptions by default (Ember.testing = false)', function () {
67839
+ QUnit.test('does not swallow exceptions by default (Ember.testing = false, no Ember.onerror) - sync run', function (assert) {
67718
67840
  _ember.default.testing = false;
67719
67841
  var error = new Error('the error');
67720
- throws(function () {
67842
+ assert.throws(function () {
67721
67843
  _ember.default.run(function () {
67722
67844
  throw error;
67723
67845
  });
67724
67846
  }, error);
67725
67847
  });
67848
+
67849
+ QUnit.test('does not swallow exceptions (Ember.testing = false, Ember.onerror which rethrows) - sync run', function (assert) {
67850
+ assert.expect(2);
67851
+ _ember.default.testing = false;
67852
+
67853
+ _ember.default.onerror = function (error) {
67854
+ assert.ok(true, 'Ember.onerror was called');
67855
+ throw error;
67856
+ };
67857
+
67858
+ var error = new Error('the error');
67859
+ assert.throws(function () {
67860
+ _ember.default.run(function () {
67861
+ throw error;
67862
+ });
67863
+ }, error);
67864
+ });
67865
+
67866
+ QUnit.test('Ember.onerror can intercept errors (aka swallow) by not rethrowing (Ember.testing = false) - sync run', function (assert) {
67867
+ assert.expect(1);
67868
+ _ember.default.testing = false;
67869
+
67870
+ _ember.default.onerror = function (error) {
67871
+ assert.ok(true, 'Ember.onerror was called');
67872
+ };
67873
+
67874
+ var error = new Error('the error');
67875
+ try {
67876
+ _ember.default.run(function () {
67877
+ throw error;
67878
+ });
67879
+ } catch (e) {
67880
+ assert.notOk(true, 'Ember.onerror that does not rethrow is intentionally swallowing errors, try / catch wrapping does not see error');
67881
+ }
67882
+ });
67883
+
67884
+ QUnit.test('does not swallow exceptions by default (Ember.testing = true, no Ember.onerror) - async run', function (assert) {
67885
+ var done = assert.async();
67886
+ var caughtByWindowOnerror = void 0;
67887
+
67888
+ _ember.default.testing = true;
67889
+
67890
+ window.onerror = function (message) {
67891
+ caughtByWindowOnerror = message;
67892
+ // prevent "bubbling" and therefore failing the test
67893
+ return true;
67894
+ };
67895
+
67896
+ _ember.default.run.later(function () {
67897
+ throw new Error('the error');
67898
+ }, 10);
67899
+
67900
+ setTimeout(function () {
67901
+ assert.pushResult({
67902
+ result: /the error/.test(caughtByWindowOnerror),
67903
+ actual: caughtByWindowOnerror,
67904
+ expected: 'to include `the error`',
67905
+ message: 'error should bubble out to window.onerror, and therefore fail tests (due to QUnit implementing window.onerror)'
67906
+ });
67907
+
67908
+ done();
67909
+ }, 20);
67910
+ });
67911
+
67912
+ QUnit.test('does not swallow exceptions by default (Ember.testing = false, no Ember.onerror) - async run', function (assert) {
67913
+ var done = assert.async();
67914
+ var caughtByWindowOnerror = void 0;
67915
+
67916
+ _ember.default.testing = false;
67917
+
67918
+ window.onerror = function (message) {
67919
+ caughtByWindowOnerror = message;
67920
+ // prevent "bubbling" and therefore failing the test
67921
+ return true;
67922
+ };
67923
+
67924
+ _ember.default.run.later(function () {
67925
+ throw new Error('the error');
67926
+ }, 10);
67927
+
67928
+ setTimeout(function () {
67929
+ assert.pushResult({
67930
+ result: /the error/.test(caughtByWindowOnerror),
67931
+ actual: caughtByWindowOnerror,
67932
+ expected: 'to include `the error`',
67933
+ message: 'error should bubble out to window.onerror, and therefore fail tests (due to QUnit implementing window.onerror)'
67934
+ });
67935
+
67936
+ done();
67937
+ }, 20);
67938
+ });
67939
+
67940
+ QUnit.test('Ember.onerror can intercept errors (aka swallow) by not rethrowing (Ember.testing = false) - async run', function (assert) {
67941
+ var done = assert.async();
67942
+
67943
+ _ember.default.testing = false;
67944
+
67945
+ window.onerror = function (message) {
67946
+ assert.notOk(true, 'window.onerror is never invoked when Ember.onerror intentionally swallows errors');
67947
+ // prevent "bubbling" and therefore failing the test
67948
+ return true;
67949
+ };
67950
+
67951
+ var thrown = new Error('the error');
67952
+ _ember.default.onerror = function (error) {
67953
+ assert.strictEqual(error, thrown, 'Ember.onerror is called with the error');
67954
+ };
67955
+
67956
+ _ember.default.run.later(function () {
67957
+ throw thrown;
67958
+ }, 10);
67959
+
67960
+ setTimeout(done, 20);
67961
+ });
67962
+
67963
+ function generateRSVPErrorHandlingTests(message, generatePromise) {
67964
+ var timeout = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 10;
67965
+
67966
+ test(message + ' when Ember.onerror which does not rethrow is present - rsvp', function (assert) {
67967
+ assert.expect(1);
67968
+
67969
+ var thrown = new Error('the error');
67970
+ _ember.default.onerror = function (error) {
67971
+ assert.strictEqual(error, thrown, 'Ember.onerror is called for errors thrown in RSVP promises');
67972
+ };
67973
+
67974
+ generatePromise(thrown);
67975
+
67976
+ // RSVP.Promise's are configured to settle within the run loop, this
67977
+ // ensures that run loop has completed
67978
+ return new _ember.default.RSVP.Promise(function (resolve) {
67979
+ return setTimeout(resolve, timeout);
67980
+ });
67981
+ });
67982
+
67983
+ test(message + ' when Ember.onerror which does rethrow is present - rsvp', function (assert) {
67984
+ assert.expect(2);
67985
+
67986
+ var thrown = new Error('the error');
67987
+ _ember.default.onerror = function (error) {
67988
+ assert.strictEqual(error, thrown, 'Ember.onerror is called for errors thrown in RSVP promises');
67989
+ throw error;
67990
+ };
67991
+
67992
+ window.onerror = function (message) {
67993
+ assert.pushResult({
67994
+ result: /the error/.test(message),
67995
+ actual: message,
67996
+ expected: 'to include `the error`',
67997
+ message: 'error should bubble out to window.onerror, and therefore fail tests (due to QUnit implementing window.onerror)'
67998
+ });
67999
+
68000
+ // prevent "bubbling" and therefore failing the test
68001
+ return true;
68002
+ };
68003
+
68004
+ generatePromise(thrown);
68005
+
68006
+ // RSVP.Promise's are configured to settle within the run loop, this
68007
+ // ensures that run loop has completed
68008
+ return new _ember.default.RSVP.Promise(function (resolve) {
68009
+ return setTimeout(resolve, timeout);
68010
+ });
68011
+ });
68012
+
68013
+ test(message + ' when Ember.onerror which does not rethrow is present (Ember.testing = false) - rsvp', function (assert) {
68014
+ assert.expect(1);
68015
+
68016
+ _ember.default.testing = false;
68017
+ var thrown = new Error('the error');
68018
+ _ember.default.onerror = function (error) {
68019
+ assert.strictEqual(error, thrown, 'Ember.onerror is called for errors thrown in RSVP promises');
68020
+ };
68021
+
68022
+ generatePromise(thrown);
68023
+
68024
+ // RSVP.Promise's are configured to settle within the run loop, this
68025
+ // ensures that run loop has completed
68026
+ return new _ember.default.RSVP.Promise(function (resolve) {
68027
+ return setTimeout(resolve, timeout);
68028
+ });
68029
+ });
68030
+
68031
+ test(message + ' when Ember.onerror which does rethrow is present (Ember.testing = false) - rsvp', function (assert) {
68032
+ assert.expect(2);
68033
+
68034
+ _ember.default.testing = false;
68035
+ var thrown = new Error('the error');
68036
+ _ember.default.onerror = function (error) {
68037
+ assert.strictEqual(error, thrown, 'Ember.onerror is called for errors thrown in RSVP promises');
68038
+ throw error;
68039
+ };
68040
+
68041
+ window.onerror = function (message) {
68042
+ assert.pushResult({
68043
+ result: /the error/.test(message),
68044
+ actual: message,
68045
+ expected: 'to include `the error`',
68046
+ message: 'error should bubble out to window.onerror, and therefore fail tests (due to QUnit implementing window.onerror)'
68047
+ });
68048
+
68049
+ // prevent "bubbling" and therefore failing the test
68050
+ return true;
68051
+ };
68052
+
68053
+ generatePromise(thrown);
68054
+
68055
+ // RSVP.Promise's are configured to settle within the run loop, this
68056
+ // ensures that run loop has completed
68057
+ return new _ember.default.RSVP.Promise(function (resolve) {
68058
+ return setTimeout(resolve, timeout);
68059
+ });
68060
+ });
68061
+
68062
+ if (true) {
68063
+ test(message + ' when Ember.Test.adapter without `exception` method is present - rsvp', function (assert) {
68064
+ assert.expect(1);
68065
+
68066
+ var thrown = new Error('the error');
68067
+ _ember.default.Test.adapter = _ember.default.Test.QUnitAdapter.create({
68068
+ exception: undefined
68069
+ });
68070
+
68071
+ window.onerror = function (message) {
68072
+ assert.pushResult({
68073
+ result: /the error/.test(message),
68074
+ actual: message,
68075
+ expected: 'to include `the error`',
68076
+ message: 'error should bubble out to window.onerror, and therefore fail tests (due to QUnit implementing window.onerror)'
68077
+ });
68078
+
68079
+ // prevent "bubbling" and therefore failing the test
68080
+ return true;
68081
+ };
68082
+
68083
+ generatePromise(thrown);
68084
+
68085
+ // RSVP.Promise's are configured to settle within the run loop, this
68086
+ // ensures that run loop has completed
68087
+ return new _ember.default.RSVP.Promise(function (resolve) {
68088
+ return setTimeout(resolve, timeout);
68089
+ });
68090
+ });
68091
+
68092
+ test(message + ' when both Ember.onerror and Ember.Test.adapter without `exception` method are present - rsvp', function (assert) {
68093
+ assert.expect(1);
68094
+
68095
+ var thrown = new Error('the error');
68096
+ _ember.default.Test.adapter = _ember.default.Test.QUnitAdapter.create({
68097
+ exception: undefined
68098
+ });
68099
+
68100
+ _ember.default.onerror = function (error) {
68101
+ assert.pushResult({
68102
+ result: /the error/.test(error.message),
68103
+ actual: error.message,
68104
+ expected: 'to include `the error`',
68105
+ message: 'error should bubble out to window.onerror, and therefore fail tests (due to QUnit implementing window.onerror)'
68106
+ });
68107
+ };
68108
+
68109
+ generatePromise(thrown);
68110
+
68111
+ // RSVP.Promise's are configured to settle within the run loop, this
68112
+ // ensures that run loop has completed
68113
+ return new _ember.default.RSVP.Promise(function (resolve) {
68114
+ return setTimeout(resolve, timeout);
68115
+ });
68116
+ });
68117
+
68118
+ test(message + ' when Ember.Test.adapter is present - rsvp', function (assert) {
68119
+ assert.expect(1);
68120
+
68121
+ var thrown = new Error('the error');
68122
+ _ember.default.Test.adapter = _ember.default.Test.QUnitAdapter.create({
68123
+ exception: function (error) {
68124
+ assert.strictEqual(error, thrown, 'Adapter.exception is called for errors thrown in RSVP promises');
68125
+ }
68126
+ });
68127
+
68128
+ generatePromise(thrown);
68129
+
68130
+ // RSVP.Promise's are configured to settle within the run loop, this
68131
+ // ensures that run loop has completed
68132
+ return new _ember.default.RSVP.Promise(function (resolve) {
68133
+ return setTimeout(resolve, timeout);
68134
+ });
68135
+ });
68136
+
68137
+ test(message + ' when both Ember.onerror and Ember.Test.adapter are present - rsvp', function (assert) {
68138
+ assert.expect(1);
68139
+
68140
+ var thrown = new Error('the error');
68141
+ _ember.default.Test.adapter = _ember.default.Test.QUnitAdapter.create({
68142
+ exception: function (error) {
68143
+ assert.strictEqual(error, thrown, 'Adapter.exception is called for errors thrown in RSVP promises');
68144
+ }
68145
+ });
68146
+
68147
+ _ember.default.onerror = function (error) {
68148
+ assert.notOk(true, 'Ember.onerror is not called if Test.adapter does not rethrow');
68149
+ };
68150
+
68151
+ generatePromise(thrown);
68152
+
68153
+ // RSVP.Promise's are configured to settle within the run loop, this
68154
+ // ensures that run loop has completed
68155
+ return new _ember.default.RSVP.Promise(function (resolve) {
68156
+ return setTimeout(resolve, timeout);
68157
+ });
68158
+ });
68159
+
68160
+ test(message + ' when both Ember.onerror and Ember.Test.adapter are present - rsvp', function (assert) {
68161
+ assert.expect(2);
68162
+
68163
+ var thrown = new Error('the error');
68164
+ _ember.default.Test.adapter = _ember.default.Test.QUnitAdapter.create({
68165
+ exception: function (error) {
68166
+ assert.strictEqual(error, thrown, 'Adapter.exception is called for errors thrown in RSVP promises');
68167
+ throw error;
68168
+ }
68169
+ });
68170
+
68171
+ _ember.default.onerror = function (error) {
68172
+ assert.strictEqual(error, thrown, 'Ember.onerror is called for errors thrown in RSVP promises if Test.adapter rethrows');
68173
+ };
68174
+
68175
+ generatePromise(thrown);
68176
+
68177
+ // RSVP.Promise's are configured to settle within the run loop, this
68178
+ // ensures that run loop has completed
68179
+ return new _ember.default.RSVP.Promise(function (resolve) {
68180
+ return setTimeout(resolve, timeout);
68181
+ });
68182
+ });
68183
+ }
68184
+ }
68185
+
68186
+ generateRSVPErrorHandlingTests('errors in promise constructor', function (error) {
68187
+ new _ember.default.RSVP.Promise(function () {
68188
+ throw error;
68189
+ });
68190
+ });
68191
+
68192
+ generateRSVPErrorHandlingTests('errors in promise .then callback', function (error) {
68193
+ _ember.default.RSVP.resolve().then(function () {
68194
+ throw error;
68195
+ });
68196
+ });
68197
+
68198
+ generateRSVPErrorHandlingTests('errors in async promise .then callback', function (error) {
68199
+ new _ember.default.RSVP.Promise(function (resolve) {
68200
+ return setTimeout(resolve, 10);
68201
+ }).then(function () {
68202
+ throw error;
68203
+ });
68204
+ }, 20);
67726
68205
  });
67727
68206
  QUnit.module('ESLint | ember/tests/error_handler_test.js');
67728
68207
  QUnit.test('should pass ESLint', function(assert) {