diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bf6c240f37..46ec05d396 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -64,6 +64,7 @@ jobs: strategy: matrix: scenario: + - default-no-prototype-extensions - release - beta - canary @@ -77,6 +78,9 @@ jobs: uses: rwjblue/setup-volta@v1 - name: Install dependencies (yarn) run: yarn install + - name: Set NO_EXTEND_PROTOTYPES + if: matrix.scenario == 'default-no-prototype-extensions' + run: echo "::set-env name=NO_EXTEND_PROTOTYPES,::true" - name: Setup ember-try scenario run: yarn ember try:one ember-${{ matrix.scenario }} --skip-cleanup --- cat package.json - name: Build diff --git a/config/ember-try.js b/config/ember-try.js index d9c4fa34dc..51e1a12b8d 100644 --- a/config/ember-try.js +++ b/config/ember-try.js @@ -65,6 +65,12 @@ module.exports = function() { npm: { devDependencies: {} } + }, + { + name: 'ember-default-no-prototype-extensions', + env: { + NO_EXTEND_PROTOTYPES: 'true' + } } ] }; diff --git a/config/environment.js b/config/environment.js index 212d9f5d4c..60d34cf10a 100644 --- a/config/environment.js +++ b/config/environment.js @@ -16,7 +16,7 @@ module.exports = function(environment) { // e.g. EMBER_MODULE_UNIFICATION: true EMBER_METAL_TRACKED_PROPERTIES: true }, - EXTEND_PROTOTYPES: { + EXTEND_PROTOTYPES: process.env.NO_EXTEND_PROTOTYPES ? false : { // Prevent Ember Data from overriding Date.parse. Date: false } diff --git a/ember_debug/adapters/web-extension.js b/ember_debug/adapters/web-extension.js index f7133d3a4f..08620da9fc 100644 --- a/ember_debug/adapters/web-extension.js +++ b/ember_debug/adapters/web-extension.js @@ -77,28 +77,36 @@ export default BasicAdapter.extend({ } }); -/** - * Recursively clones all arrays. Needed because Chrome - * refuses to clone Ember Arrays when extend prototypes is disabled. - * - * If the item passed is an array, a clone of the array is returned. - * If the item is an object or an array, or array properties/items are cloned. - * - * @param {Mixed} item The item to clone - * @return {Mixed} - */ -function deepClone(item) { - let clone = item; - if (isArray(item)) { - clone = new Array(item.length); - item.forEach((child, key) => { - clone[key] = deepClone(child); - }); - } else if (item && typeOf(item) === 'object') { - clone = {}; - keys(item).forEach(key => { - clone[key] = deepClone(item[key]); - }); - } - return clone; +let deepClone; + +if (Ember.ENV.EXTEND_PROTOTYPES.Array) { + deepClone = function deepClone(item) { + return item; + }; +} else { + /** + * Recursively clones all arrays. Needed because Chrome + * refuses to clone Ember Arrays when extend prototypes is disabled. + * + * If the item passed is an array, a clone of the array is returned. + * If the item is an object or an array, or array properties/items are cloned. + * + * @param {Mixed} item The item to clone + * @return {Mixed} + */ + deepClone = function deepClone(item) { + let clone = item; + if (isArray(item)) { + clone = new Array(item.length); + item.forEach((child, key) => { + clone[key] = deepClone(child); + }); + } else if (item && typeOf(item) === 'object') { + clone = {}; + keys(item).forEach(key => { + clone[key] = deepClone(item[key]); + }); + } + return clone; + }; } diff --git a/tests/ember_debug/deprecation-debug-test.js b/tests/ember_debug/deprecation-debug-test.js index d72872da6d..1ed1e7c8fb 100644 --- a/tests/ember_debug/deprecation-debug-test.js +++ b/tests/ember_debug/deprecation-debug-test.js @@ -34,10 +34,15 @@ module('Ember Debug - Deprecation', function(hooks) { }); test('deprecations are caught and sent', async function t(assert) { - let messages = []; + let deprecations, count; + port.reopen({ send(name, message) { - messages.push({ name, message }); + if (name === 'deprecation:deprecationsAdded') { + deprecations = message.deprecations; + } else if (name === 'deprecation:count') { + count = message.count; + } } }); @@ -52,20 +57,22 @@ module('Ember Debug - Deprecation', function(hooks) { }); run(port, 'trigger', 'deprecation:watch'); + await visit('/'); - let deprecations = messages.filterBy('name', 'deprecation:deprecationsAdded').get('lastObject').message.deprecations; + assert.equal(deprecations.length, 2); + let deprecation = deprecations[0]; assert.equal(deprecation.count, 2, 'Correctly combined'); assert.equal(deprecation.message, 'Deprecation 1'); assert.equal(deprecation.sources.length, 2, 'Correctly separated by source'); + deprecation = deprecations[1]; assert.equal(deprecation.count, 1); assert.equal(deprecation.message, 'Deprecation 2'); assert.equal(deprecation.sources.length, 1); assert.equal(deprecation.url, 'http://www.emberjs.com'); - let count = messages.filterBy('name', 'deprecation:count').get('lastObject').message.count; assert.equal(count, 3, 'count correctly sent'); });