dist/ember-testing.js in ember-source-2.14.0.beta.2 vs dist/ember-testing.js in ember-source-2.14.0.beta.3

- old
+ new

@@ -4,11 +4,11 @@ * @copyright Copyright 2011-2017 Tilde Inc. and contributors * Portions Copyright 2006-2011 Strobe Inc. * Portions Copyright 2008-2011 Apple Inc. All rights reserved. * @license Licensed under MIT license * See https://raw.github.com/emberjs/ember.js/master/LICENSE - * @version 2.14.0-beta.2 + * @version 2.14.0-beta.3 */ var enifed, requireModule, Ember; var mainContext = this; // Used in ember-environment/lib/global.js @@ -186,16 +186,19 @@ var slice = exports.slice = Array.prototype.slice; }); enifed('ember-debug/deprecate', ['exports', 'ember-debug/error', 'ember-console', 'ember-environment', 'ember-debug/handlers'], function (exports, _error, _emberConsole, _emberEnvironment, _handlers) { 'use strict'; - exports.missingOptionsUntilDeprecation = exports.missingOptionsIdDeprecation = exports.missingOptionsDeprecation = undefined; - exports.registerHandler = registerHandler; - exports.default = deprecate; + exports.missingOptionsUntilDeprecation = exports.missingOptionsIdDeprecation = exports.missingOptionsDeprecation = exports.registerHandler = undefined; /** + @module ember + @submodule ember-debug + */ + + /** Allows for runtime registration of handler functions that override the default deprecation behavior. Deprecations are invoked by calls to [Ember.deprecate](http://emberjs.com/api/classes/Ember.html#method_deprecate). The following example demonstrates its usage by registering a handler that throws an error if the message contains the word "should", otherwise defers to the default handler. @@ -226,148 +229,154 @@ @static @method registerDeprecationHandler @param handler {Function} A function to handle deprecation calls. @since 2.1.0 */ - /*global __fail__*/ + var registerHandler = function () {}; /*global __fail__*/ - function registerHandler(handler) { - (0, _handlers.registerHandler)('deprecate', handler); - } + var missingOptionsDeprecation = void 0, + missingOptionsIdDeprecation = void 0, + missingOptionsUntilDeprecation = void 0, + deprecate = void 0; - function formatMessage(_message, options) { - var message = _message; + if (true) { + exports.registerHandler = registerHandler = function registerHandler(handler) { + (0, _handlers.registerHandler)('deprecate', handler); + }; - if (options && options.id) { - message = message + (' [deprecation id: ' + options.id + ']'); - } + var formatMessage = function formatMessage(_message, options) { + var message = _message; - if (options && options.url) { - message += ' See ' + options.url + ' for more details.'; - } + if (options && options.id) { + message = message + (' [deprecation id: ' + options.id + ']'); + } - return message; - } + if (options && options.url) { + message += ' See ' + options.url + ' for more details.'; + } - registerHandler(function logDeprecationToConsole(message, options) { - var updatedMessage = formatMessage(message, options); + return message; + }; - _emberConsole.default.warn('DEPRECATION: ' + updatedMessage); - }); + registerHandler(function logDeprecationToConsole(message, options) { + var updatedMessage = formatMessage(message, options); - var captureErrorForStack = void 0; + _emberConsole.default.warn('DEPRECATION: ' + updatedMessage); + }); - if (new Error().stack) { - captureErrorForStack = function () { - return new Error(); - }; - } else { - captureErrorForStack = function () { - try { - __fail__.fail(); - } catch (e) { - return e; - } - }; - } + var captureErrorForStack = void 0; - registerHandler(function logDeprecationStackTrace(message, options, next) { - if (_emberEnvironment.ENV.LOG_STACKTRACE_ON_DEPRECATION) { - var stackStr = ''; - var error = captureErrorForStack(); - var stack = void 0; - - if (error.stack) { - if (error['arguments']) { - // Chrome - stack = error.stack.replace(/^\s+at\s+/gm, '').replace(/^([^\(]+?)([\n$])/gm, '{anonymous}($1)$2').replace(/^Object.<anonymous>\s*\(([^\)]+)\)/gm, '{anonymous}($1)').split('\n'); - stack.shift(); - } else { - // Firefox - stack = error.stack.replace(/(?:\n@:0)?\s+$/m, '').replace(/^\(/gm, '{anonymous}(').split('\n'); + if (new Error().stack) { + captureErrorForStack = function () { + return new Error(); + }; + } else { + captureErrorForStack = function () { + try { + __fail__.fail(); + } catch (e) { + return e; } + }; + } - stackStr = '\n ' + stack.slice(2).join('\n '); - } + registerHandler(function logDeprecationStackTrace(message, options, next) { + if (_emberEnvironment.ENV.LOG_STACKTRACE_ON_DEPRECATION) { + var stackStr = ''; + var error = captureErrorForStack(); + var stack = void 0; - var updatedMessage = formatMessage(message, options); + if (error.stack) { + if (error['arguments']) { + // Chrome + stack = error.stack.replace(/^\s+at\s+/gm, '').replace(/^([^\(]+?)([\n$])/gm, '{anonymous}($1)$2').replace(/^Object.<anonymous>\s*\(([^\)]+)\)/gm, '{anonymous}($1)').split('\n'); + stack.shift(); + } else { + // Firefox + stack = error.stack.replace(/(?:\n@:0)?\s+$/m, '').replace(/^\(/gm, '{anonymous}(').split('\n'); + } - _emberConsole.default.warn('DEPRECATION: ' + updatedMessage + stackStr); - } else { - next.apply(undefined, arguments); - } - }); + stackStr = '\n ' + stack.slice(2).join('\n '); + } - registerHandler(function raiseOnDeprecation(message, options, next) { - if (_emberEnvironment.ENV.RAISE_ON_DEPRECATION) { - var updatedMessage = formatMessage(message); + var updatedMessage = formatMessage(message, options); - throw new _error.default(updatedMessage); - } else { - next.apply(undefined, arguments); - } - }); + _emberConsole.default.warn('DEPRECATION: ' + updatedMessage + stackStr); + } else { + next.apply(undefined, arguments); + } + }); - var missingOptionsDeprecation = exports.missingOptionsDeprecation = 'When calling `Ember.deprecate` you ' + 'must provide an `options` hash as the third parameter. ' + '`options` should include `id` and `until` properties.'; - var missingOptionsIdDeprecation = exports.missingOptionsIdDeprecation = 'When calling `Ember.deprecate` you must provide `id` in options.'; - var missingOptionsUntilDeprecation = exports.missingOptionsUntilDeprecation = 'When calling `Ember.deprecate` you must provide `until` in options.'; + registerHandler(function raiseOnDeprecation(message, options, next) { + if (_emberEnvironment.ENV.RAISE_ON_DEPRECATION) { + var updatedMessage = formatMessage(message); - /** - @module ember - @submodule ember-debug - */ + throw new _error.default(updatedMessage); + } else { + next.apply(undefined, arguments); + } + }); - /** - Display a deprecation warning with the provided message and a stack trace - (Chrome and Firefox only). - - * In a production build, this method is defined as an empty function (NOP). - Uses of this method in Ember itself are stripped from the ember.prod.js build. - - @method deprecate - @param {String} message A description of the deprecation. - @param {Boolean} test A boolean. If falsy, the deprecation will be displayed. - @param {Object} options - @param {String} options.id A unique id for this deprecation. The id can be - used by Ember debugging tools to change the behavior (raise, log or silence) - for that specific deprecation. The id should be namespaced by dots, e.g. - "view.helper.select". - @param {string} options.until The version of Ember when this deprecation - warning will be removed. - @param {String} [options.url] An optional url to the transition guide on the - emberjs.com website. - @for Ember - @public - @since 1.0.0 - */ - function deprecate(message, test, options) { - if (!options || !options.id && !options.until) { - deprecate(missingOptionsDeprecation, false, { - id: 'ember-debug.deprecate-options-missing', - until: '3.0.0', - url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options' - }); - } + exports.missingOptionsDeprecation = missingOptionsDeprecation = 'When calling `Ember.deprecate` you ' + 'must provide an `options` hash as the third parameter. ' + '`options` should include `id` and `until` properties.'; + exports.missingOptionsIdDeprecation = missingOptionsIdDeprecation = 'When calling `Ember.deprecate` you must provide `id` in options.'; + exports.missingOptionsUntilDeprecation = missingOptionsUntilDeprecation = 'When calling `Ember.deprecate` you must provide `until` in options.'; - if (options && !options.id) { - deprecate(missingOptionsIdDeprecation, false, { - id: 'ember-debug.deprecate-id-missing', - until: '3.0.0', - url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options' - }); - } + /** + Display a deprecation warning with the provided message and a stack trace + (Chrome and Firefox only). + * In a production build, this method is defined as an empty function (NOP). + Uses of this method in Ember itself are stripped from the ember.prod.js build. + @method deprecate + @param {String} message A description of the deprecation. + @param {Boolean} test A boolean. If falsy, the deprecation will be displayed. + @param {Object} options + @param {String} options.id A unique id for this deprecation. The id can be + used by Ember debugging tools to change the behavior (raise, log or silence) + for that specific deprecation. The id should be namespaced by dots, e.g. + "view.helper.select". + @param {string} options.until The version of Ember when this deprecation + warning will be removed. + @param {String} [options.url] An optional url to the transition guide on the + emberjs.com website. + @for Ember + @public + @since 1.0.0 + */ + deprecate = function deprecate(message, test, options) { + if (!options || !options.id && !options.until) { + deprecate(missingOptionsDeprecation, false, { + id: 'ember-debug.deprecate-options-missing', + until: '3.0.0', + url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options' + }); + } - if (options && !options.until) { - deprecate(missingOptionsUntilDeprecation, options && options.until, { - id: 'ember-debug.deprecate-until-missing', - until: '3.0.0', - url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options' - }); - } + if (options && !options.id) { + deprecate(missingOptionsIdDeprecation, false, { + id: 'ember-debug.deprecate-id-missing', + until: '3.0.0', + url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options' + }); + } - _handlers.invoke.apply(undefined, ['deprecate'].concat(Array.prototype.slice.call(arguments))); + if (options && !options.until) { + deprecate(missingOptionsUntilDeprecation, options && options.until, { + id: 'ember-debug.deprecate-until-missing', + until: '3.0.0', + url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options' + }); + } + + _handlers.invoke.apply(undefined, ['deprecate'].concat(Array.prototype.slice.call(arguments))); + }; } + + exports.default = deprecate; + exports.registerHandler = registerHandler; + exports.missingOptionsDeprecation = missingOptionsDeprecation; + exports.missingOptionsIdDeprecation = missingOptionsIdDeprecation; + exports.missingOptionsUntilDeprecation = missingOptionsUntilDeprecation; }); enifed("ember-debug/error", ["exports", "ember-babel"], function (exports, _emberBabel) { "use strict"; function ExtendBuiltin(klass) { @@ -476,41 +485,47 @@ } else { return false; } } }); -enifed("ember-debug/handlers", ["exports"], function (exports) { - "use strict"; +enifed('ember-debug/handlers', ['exports'], function (exports) { + 'use strict'; - exports.registerHandler = registerHandler; - exports.invoke = invoke; var HANDLERS = exports.HANDLERS = {}; - function registerHandler(type, callback) { - var nextHandler = HANDLERS[type] || function () {}; + var registerHandler = function () {}; + var invoke = function () {}; - HANDLERS[type] = function (message, options) { - callback(message, options, nextHandler); + if (true) { + exports.registerHandler = registerHandler = function registerHandler(type, callback) { + var nextHandler = HANDLERS[type] || function () {}; + + HANDLERS[type] = function (message, options) { + callback(message, options, nextHandler); + }; }; - } - function invoke(type, message, test, options) { - if (test) { - return; - } + exports.invoke = invoke = function invoke(type, message, test, options) { + if (test) { + return; + } - var handlerForType = HANDLERS[type]; + var handlerForType = HANDLERS[type]; - if (handlerForType) { - handlerForType(message, options); - } + if (handlerForType) { + handlerForType(message, options); + } + }; } + + exports.registerHandler = registerHandler; + exports.invoke = invoke; }); enifed('ember-debug/index', ['exports', 'ember-debug/warn', 'ember-debug/deprecate', 'ember-debug/features', 'ember-debug/error', 'ember-debug/testing', 'ember-environment', 'ember-console', 'ember/features'], function (exports, _warn2, _deprecate2, _features, _error, _testing, _emberEnvironment, _emberConsole, _features2) { 'use strict'; - exports.runningNonEmberDebugJS = exports.debugFunctions = exports.setTesting = exports.isTesting = exports.Error = exports.isFeatureEnabled = exports.registerDeprecationHandler = exports.registerWarnHandler = undefined; + exports._warnIfUsingStrippedFeatureFlags = exports.getDebugFunction = exports.setDebugFunction = exports.deprecateFunc = exports.runInDebug = exports.debugFreeze = exports.debugSeal = exports.deprecate = exports.debug = exports.warn = exports.info = exports.assert = exports.setTesting = exports.isTesting = exports.Error = exports.isFeatureEnabled = exports.registerDeprecationHandler = exports.registerWarnHandler = undefined; Object.defineProperty(exports, 'registerWarnHandler', { enumerable: true, get: function () { return _warn2.registerHandler; } @@ -543,216 +558,242 @@ enumerable: true, get: function () { return _testing.setTesting; } }); - exports._warnIfUsingStrippedFeatureFlags = _warnIfUsingStrippedFeatureFlags; - exports.getDebugFunction = getDebugFunction; - exports.setDebugFunction = setDebugFunction; - exports.assert = assert; - exports.info = info; - exports.warn = warn; - exports.debug = debug; - exports.deprecate = deprecate; - exports.deprecateFunc = deprecateFunc; - exports.runInDebug = runInDebug; - exports.debugSeal = debugSeal; - exports.debugFreeze = debugFreeze; var DEFAULT_FEATURES = _features2.DEFAULT_FEATURES, FEATURES = _features2.FEATURES; - var debugFunctions = exports.debugFunctions = { - assert: function () {}, - info: function () {}, - warn: function () {}, - debug: function () {}, - deprecate: function () {}, - deprecateFunc: function () { - var _ref; - return _ref = arguments.length - 1, arguments.length <= _ref ? undefined : arguments[_ref]; - }, - debugSeal: function () {}, - debugFreeze: function () {} + + // These are the default production build versions: + var assert = function () {}; + var info = function () {}; + var warn = function () {}; + var debug = function () {}; + var deprecate = function () {}; + var debugSeal = function () {}; + var debugFreeze = function () {}; + var runInDebug = function () {}; + + var deprecateFunc = function () { + return arguments[arguments.length - 1]; }; + var setDebugFunction = function () {}; + var getDebugFunction = function () {}; + + if (true) { + exports.setDebugFunction = setDebugFunction = function (type, callback) { + switch (type) { + case 'assert': + return exports.assert = assert = callback; + case 'info': + return exports.info = info = callback; + case 'warn': + return exports.warn = warn = callback; + case 'debug': + return exports.debug = debug = callback; + case 'deprecate': + return exports.deprecate = deprecate = callback; + case 'debugSeal': + return exports.debugSeal = debugSeal = callback; + case 'debugFreeze': + return exports.debugFreeze = debugFreeze = callback; + case 'runInDebug': + return exports.runInDebug = runInDebug = callback; + case 'deprecateFunc': + return exports.deprecateFunc = deprecateFunc = callback; + } + }; + + exports.getDebugFunction = getDebugFunction = function (type) { + switch (type) { + case 'assert': + return assert; + case 'info': + return info; + case 'warn': + return warn; + case 'debug': + return debug; + case 'deprecate': + return deprecate; + case 'debugSeal': + return debugSeal; + case 'debugFreeze': + return debugFreeze; + case 'runInDebug': + return runInDebug; + case 'deprecateFunc': + return deprecateFunc; + } + }; + } + /** @module ember @submodule ember-debug */ /** @class Ember @public */ - /** - Define an assertion that will throw an exception if the condition is not met. - - * In a production build, this method is defined as an empty function (NOP). - Uses of this method in Ember itself are stripped from the ember.prod.js build. - - ```javascript - // Test for truthiness - Ember.assert('Must pass a valid object', obj); - - // Fail unconditionally - Ember.assert('This code path should never be run'); - ``` - - @method assert - @param {String} desc A description of the assertion. This will become - the text of the Error thrown if the assertion fails. - @param {Boolean} test Must be truthy for the assertion to pass. If - falsy, an exception will be thrown. - @public - @since 1.0.0 - */ - setDebugFunction('assert', function assert(desc, test) { - if (!test) { - throw new _error.default('Assertion Failed: ' + desc); - } - }); + if (true) { + /** + Define an assertion that will throw an exception if the condition is not met. + * In a production build, this method is defined as an empty function (NOP). + Uses of this method in Ember itself are stripped from the ember.prod.js build. + ```javascript + // Test for truthiness + Ember.assert('Must pass a valid object', obj); + // Fail unconditionally + Ember.assert('This code path should never be run'); + ``` + @method assert + @param {String} desc A description of the assertion. This will become + the text of the Error thrown if the assertion fails. + @param {Boolean} test Must be truthy for the assertion to pass. If + falsy, an exception will be thrown. + @public + @since 1.0.0 + */ + setDebugFunction('assert', function assert(desc, test) { + if (!test) { + throw new _error.default('Assertion Failed: ' + desc); + } + }); - /** - Display a debug notice. - - * In a production build, this method is defined as an empty function (NOP). - Uses of this method in Ember itself are stripped from the ember.prod.js build. - - ```javascript - Ember.debug('I\'m a debug notice!'); - ``` - - @method debug - @param {String} message A debug message to display. - @public - */ - setDebugFunction('debug', function debug(message) { - _emberConsole.default.debug('DEBUG: ' + message); - }); + /** + Display a debug notice. + * In a production build, this method is defined as an empty function (NOP). + Uses of this method in Ember itself are stripped from the ember.prod.js build. + ```javascript + Ember.debug('I\'m a debug notice!'); + ``` + @method debug + @param {String} message A debug message to display. + @public + */ + setDebugFunction('debug', function debug(message) { + _emberConsole.default.debug('DEBUG: ' + message); + }); - /** - Display an info notice. - - * In a production build, this method is defined as an empty function (NOP). - Uses of this method in Ember itself are stripped from the ember.prod.js build. - - @method info - @private - */ - setDebugFunction('info', function info() { - _emberConsole.default.info.apply(undefined, arguments); - }); + /** + Display an info notice. + * In a production build, this method is defined as an empty function (NOP). + Uses of this method in Ember itself are stripped from the ember.prod.js build. + @method info + @private + */ + setDebugFunction('info', function info() { + _emberConsole.default.info.apply(undefined, arguments); + }); - /** - Alias an old, deprecated method with its new counterpart. - - Display a deprecation warning with the provided message and a stack trace - (Chrome and Firefox only) when the assigned method is called. - - * In a production build, this method is defined as an empty function (NOP). - - ```javascript - Ember.oldMethod = Ember.deprecateFunc('Please use the new, updated method', Ember.newMethod); - ``` - - @method deprecateFunc - @param {String} message A description of the deprecation. - @param {Object} [options] The options object for Ember.deprecate. - @param {Function} func The new function called to replace its deprecated counterpart. - @return {Function} A new function that wraps the original function with a deprecation warning - @private - */ - setDebugFunction('deprecateFunc', function deprecateFunc() { - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } + /** + Alias an old, deprecated method with its new counterpart. + Display a deprecation warning with the provided message and a stack trace + (Chrome and Firefox only) when the assigned method is called. + * In a production build, this method is defined as an empty function (NOP). + ```javascript + Ember.oldMethod = Ember.deprecateFunc('Please use the new, updated method', Ember.newMethod); + ``` + @method deprecateFunc + @param {String} message A description of the deprecation. + @param {Object} [options] The options object for Ember.deprecate. + @param {Function} func The new function called to replace its deprecated counterpart. + @return {Function} A new function that wraps the original function with a deprecation warning + @private + */ + setDebugFunction('deprecateFunc', function deprecateFunc() { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } - if (args.length === 3) { - var message = args[0], - options = args[1], - func = args[2]; + if (args.length === 3) { + var message = args[0], + options = args[1], + func = args[2]; - return function () { - deprecate(message, false, options); - return func.apply(this, arguments); - }; - } else { - var _message = args[0], - _func = args[1]; + return function () { + deprecate(message, false, options); + return func.apply(this, arguments); + }; + } else { + var _message = args[0], + _func = args[1]; - return function () { - deprecate(_message); - return _func.apply(this, arguments); - }; - } - }); + return function () { + deprecate(_message); + return _func.apply(this, arguments); + }; + } + }); - /** - Run a function meant for debugging. - - * In a production build, this method is defined as an empty function (NOP). - Uses of this method in Ember itself are stripped from the ember.prod.js build. - - ```javascript - Ember.runInDebug(() => { - Ember.Component.reopen({ - didInsertElement() { - console.log("I'm happy"); - } + /** + Run a function meant for debugging. + * In a production build, this method is defined as an empty function (NOP). + Uses of this method in Ember itself are stripped from the ember.prod.js build. + ```javascript + Ember.runInDebug(() => { + Ember.Component.reopen({ + didInsertElement() { + console.log("I'm happy"); + } + }); }); + ``` + @method runInDebug + @param {Function} func The function to be executed. + @since 1.5.0 + @public + */ + setDebugFunction('runInDebug', function runInDebug(func) { + func(); }); - ``` - - @method runInDebug - @param {Function} func The function to be executed. - @since 1.5.0 - @public - */ - setDebugFunction('runInDebug', function runInDebug(func) { - func(); - }); - setDebugFunction('debugSeal', function debugSeal(obj) { - Object.seal(obj); - }); + setDebugFunction('debugSeal', function debugSeal(obj) { + Object.seal(obj); + }); - setDebugFunction('debugFreeze', function debugFreeze(obj) { - Object.freeze(obj); - }); + setDebugFunction('debugFreeze', function debugFreeze(obj) { + Object.freeze(obj); + }); - setDebugFunction('deprecate', _deprecate2.default); + setDebugFunction('deprecate', _deprecate2.default); - setDebugFunction('warn', _warn2.default); + setDebugFunction('warn', _warn2.default); + } - /** - Will call `Ember.warn()` if ENABLE_OPTIONAL_FEATURES or - any specific FEATURES flag is truthy. - - This method is called automatically in debug canary builds. - - @private - @method _warnIfUsingStrippedFeatureFlags - @return {void} - */ - function _warnIfUsingStrippedFeatureFlags(FEATURES, knownFeatures, featuresWereStripped) { - if (featuresWereStripped) { - warn('Ember.ENV.ENABLE_OPTIONAL_FEATURES is only available in canary builds.', !_emberEnvironment.ENV.ENABLE_OPTIONAL_FEATURES, { id: 'ember-debug.feature-flag-with-features-stripped' }); + var _warnIfUsingStrippedFeatureFlags = void 0; - var keys = Object.keys(FEATURES || {}); - for (var i = 0; i < keys.length; i++) { - var key = keys[i]; - if (key === 'isEnabled' || !(key in knownFeatures)) { - continue; - } + if (true && !(0, _testing.isTesting)()) { + /** + Will call `Ember.warn()` if ENABLE_OPTIONAL_FEATURES or + any specific FEATURES flag is truthy. + This method is called automatically in debug canary builds. + @private + @method _warnIfUsingStrippedFeatureFlags + @return {void} + */ + exports._warnIfUsingStrippedFeatureFlags = _warnIfUsingStrippedFeatureFlags = function _warnIfUsingStrippedFeatureFlags(FEATURES, knownFeatures, featuresWereStripped) { + if (featuresWereStripped) { + warn('Ember.ENV.ENABLE_OPTIONAL_FEATURES is only available in canary builds.', !_emberEnvironment.ENV.ENABLE_OPTIONAL_FEATURES, { id: 'ember-debug.feature-flag-with-features-stripped' }); - warn('FEATURE["' + key + '"] is set as enabled, but FEATURE flags are only available in canary builds.', !FEATURES[key], { id: 'ember-debug.feature-flag-with-features-stripped' }); + var keys = Object.keys(FEATURES || {}); + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + if (key === 'isEnabled' || !(key in knownFeatures)) { + continue; + } + + warn('FEATURE["' + key + '"] is set as enabled, but FEATURE flags are only available in canary builds.', !FEATURES[key], { id: 'ember-debug.feature-flag-with-features-stripped' }); + } } - } - } + }; - if (!(0, _testing.isTesting)()) { // Complain if they're using FEATURE flags in builds other than canary FEATURES['features-stripped-test'] = true; var featuresWereStripped = true; if ((0, _features.default)('features-stripped-test')) { @@ -781,70 +822,23 @@ } }, false); } } - /* - We are transitioning away from `ember.js` to `ember.debug.js` to make - it much clearer that it is only for local development purposes. - - This flag value is changed by the tooling (by a simple string replacement) - so that if `ember.js` (which must be output for backwards compat reasons) is - used a nice helpful warning message will be printed out. - */ - var runningNonEmberDebugJS = exports.runningNonEmberDebugJS = false; - if (runningNonEmberDebugJS) { - warn('Please use `ember.debug.js` instead of `ember.js` for development and debugging.'); - } - - function getDebugFunction(name) { - return debugFunctions[name]; - } - - function setDebugFunction(name, fn) { - debugFunctions[name] = fn; - } - - function assert() { - return debugFunctions.assert.apply(undefined, arguments); - } - - function info() { - return debugFunctions.info.apply(undefined, arguments); - } - - function warn() { - return debugFunctions.warn.apply(undefined, arguments); - } - - function debug() { - return debugFunctions.debug.apply(undefined, arguments); - } - - function deprecate() { - return debugFunctions.deprecate.apply(undefined, arguments); - } - - function deprecateFunc() { - return debugFunctions.deprecateFunc.apply(undefined, arguments); - } - - function runInDebug() { - return debugFunctions.runInDebug.apply(undefined, arguments); - } - - function debugSeal() { - return debugFunctions.debugSeal.apply(undefined, arguments); - } - - function debugFreeze() { - return debugFunctions.debugFreeze.apply(undefined, arguments); - } + exports.assert = assert; + exports.info = info; + exports.warn = warn; + exports.debug = debug; + exports.deprecate = deprecate; + exports.debugSeal = debugSeal; + exports.debugFreeze = debugFreeze; + exports.runInDebug = runInDebug; + exports.deprecateFunc = deprecateFunc; + exports.setDebugFunction = setDebugFunction; + exports.getDebugFunction = getDebugFunction; + exports._warnIfUsingStrippedFeatureFlags = _warnIfUsingStrippedFeatureFlags; }); -enifed("ember-debug/run-in-debug", [], function () { - "use strict"; -}); enifed("ember-debug/testing", ["exports"], function (exports) { "use strict"; exports.isTesting = isTesting; exports.setTesting = setTesting; @@ -859,103 +853,107 @@ } }); enifed('ember-debug/warn', ['exports', 'ember-console', 'ember-debug/deprecate', 'ember-debug/handlers'], function (exports, _emberConsole, _deprecate, _handlers) { 'use strict'; - exports.missingOptionsIdDeprecation = exports.missingOptionsDeprecation = undefined; - exports.registerHandler = registerHandler; - exports.default = warn; + exports.missingOptionsDeprecation = exports.missingOptionsIdDeprecation = exports.registerHandler = undefined; - /** - Allows for runtime registration of handler functions that override the default warning behavior. - Warnings are invoked by calls made to [Ember.warn](http://emberjs.com/api/classes/Ember.html#method_warn). - The following example demonstrates its usage by registering a handler that does nothing overriding Ember's - default warning behavior. - - ```javascript - // next is not called, so no warnings get the default behavior - Ember.Debug.registerWarnHandler(() => {}); - ``` - - The handler function takes the following arguments: - - <ul> - <li> <code>message</code> - The message received from the warn call. </li> - <li> <code>options</code> - An object passed in with the warn call containing additional information including:</li> - <ul> - <li> <code>id</code> - An id of the warning in the form of <code>package-name.specific-warning</code>.</li> - </ul> - <li> <code>next</code> - A function that calls into the previously registered handler.</li> - </ul> - - @public - @static - @method registerWarnHandler - @param handler {Function} A function to handle warnings. - @since 2.1.0 - */ - function registerHandler(handler) { - (0, _handlers.registerHandler)('warn', handler); - } + var registerHandler = function () {}; + var warn = function () {}; + var missingOptionsDeprecation = void 0, + missingOptionsIdDeprecation = void 0; - registerHandler(function logWarning(message, options) { - _emberConsole.default.warn('WARNING: ' + message); - if ('trace' in _emberConsole.default) { - _emberConsole.default.trace(); - } - }); - - var missingOptionsDeprecation = exports.missingOptionsDeprecation = 'When calling `Ember.warn` you ' + 'must provide an `options` hash as the third parameter. ' + '`options` should include an `id` property.'; - var missingOptionsIdDeprecation = exports.missingOptionsIdDeprecation = 'When calling `Ember.warn` you must provide `id` in options.'; - /** @module ember @submodule ember-debug */ - /** - Display a warning with the provided message. - - * In a production build, this method is defined as an empty function (NOP). - Uses of this method in Ember itself are stripped from the ember.prod.js build. - - @method warn - @param {String} message A warning to display. - @param {Boolean} test An optional boolean. If falsy, the warning - will be displayed. - @param {Object} options An object that can be used to pass a unique - `id` for this warning. The `id` can be used by Ember debugging tools - to change the behavior (raise, log, or silence) for that specific warning. - The `id` should be namespaced by dots, e.g. "ember-debug.feature-flag-with-features-stripped" - @for Ember - @public - @since 1.0.0 - */ - function warn(message, test, options) { - if (arguments.length === 2 && typeof test === 'object') { - options = test; - test = false; - } - if (!options) { - (0, _deprecate.default)(missingOptionsDeprecation, false, { - id: 'ember-debug.warn-options-missing', - until: '3.0.0', - url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options' - }); - } + if (true) { + /** + Allows for runtime registration of handler functions that override the default warning behavior. + Warnings are invoked by calls made to [Ember.warn](http://emberjs.com/api/classes/Ember.html#method_warn). + The following example demonstrates its usage by registering a handler that does nothing overriding Ember's + default warning behavior. + ```javascript + // next is not called, so no warnings get the default behavior + Ember.Debug.registerWarnHandler(() => {}); + ``` + The handler function takes the following arguments: + <ul> + <li> <code>message</code> - The message received from the warn call. </li> + <li> <code>options</code> - An object passed in with the warn call containing additional information including:</li> + <ul> + <li> <code>id</code> - An id of the warning in the form of <code>package-name.specific-warning</code>.</li> + </ul> + <li> <code>next</code> - A function that calls into the previously registered handler.</li> + </ul> + @public + @static + @method registerWarnHandler + @param handler {Function} A function to handle warnings. + @since 2.1.0 + */ + exports.registerHandler = registerHandler = function registerHandler(handler) { + (0, _handlers.registerHandler)('warn', handler); + }; - if (options && !options.id) { - (0, _deprecate.default)(missingOptionsIdDeprecation, false, { - id: 'ember-debug.warn-id-missing', - until: '3.0.0', - url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options' - }); - } + registerHandler(function logWarning(message, options) { + _emberConsole.default.warn('WARNING: ' + message); + if ('trace' in _emberConsole.default) { + _emberConsole.default.trace(); + } + }); - (0, _handlers.invoke)('warn', message, test, options); + exports.missingOptionsDeprecation = missingOptionsDeprecation = 'When calling `Ember.warn` you ' + 'must provide an `options` hash as the third parameter. ' + '`options` should include an `id` property.'; + exports.missingOptionsIdDeprecation = missingOptionsIdDeprecation = 'When calling `Ember.warn` you must provide `id` in options.'; + + /** + Display a warning with the provided message. + * In a production build, this method is defined as an empty function (NOP). + Uses of this method in Ember itself are stripped from the ember.prod.js build. + @method warn + @param {String} message A warning to display. + @param {Boolean} test An optional boolean. If falsy, the warning + will be displayed. + @param {Object} options An object that can be used to pass a unique + `id` for this warning. The `id` can be used by Ember debugging tools + to change the behavior (raise, log, or silence) for that specific warning. + The `id` should be namespaced by dots, e.g. "ember-debug.feature-flag-with-features-stripped" + @for Ember + @public + @since 1.0.0 + */ + warn = function warn(message, test, options) { + if (arguments.length === 2 && typeof test === 'object') { + options = test; + test = false; + } + if (!options) { + (0, _deprecate.default)(missingOptionsDeprecation, false, { + id: 'ember-debug.warn-options-missing', + until: '3.0.0', + url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options' + }); + } + + if (options && !options.id) { + (0, _deprecate.default)(missingOptionsIdDeprecation, false, { + id: 'ember-debug.warn-id-missing', + until: '3.0.0', + url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options' + }); + } + + (0, _handlers.invoke)('warn', message, test, options); + }; } + + exports.default = warn; + exports.registerHandler = registerHandler; + exports.missingOptionsIdDeprecation = missingOptionsIdDeprecation; + exports.missingOptionsDeprecation = missingOptionsDeprecation; }); enifed('ember-testing/adapters/adapter', ['exports', 'ember-runtime'], function (exports, _emberRuntime) { 'use strict'; function K() { @@ -1643,10 +1641,10 @@ /** @module ember @submodule ember-testing */ function resumeTest() { - (true && (0, _emberDebug.assert)('Testing has not been paused. There is nothing to resume.', resume)); + (true && !(resume) && (0, _emberDebug.assert)('Testing has not been paused. There is nothing to resume.', resume)); resume(); resume = undefined; }