-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re-add possibility to enable feature flags within Browser
Optional feature flags can now be enabled via a checkbox, rendered at the top of the test page. The state of the checkbox is set as query parameter in the URL. An in-repo-addon ensures that the ENABLE_OPTIONAL_FEATURES flag works correctly, when the tests are run inside a browser: the workaround using the in-repo-addon is needed, since the flag needs to be set before Ember.js is loaded, but there is currently no other way.
- Loading branch information
Showing
4 changed files
with
38 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/*jshint node:true*/ | ||
module.exports = { | ||
name: 'enable-optional-features-via-url', | ||
|
||
/** | ||
So the ENABLE_OPTIONAL_FEATURES flag is considered correctly within the | ||
index.html, it needs to be set before Ember.js is loaded. Since there is | ||
currently no way to access the `window` object within config/environment.js | ||
(and hereby check if there is a query parameter present for the checkbox), | ||
a script is injected, before Ember.js is loaded. The script checks if there | ||
is no value yet for the ENABLE_OPTIONAL_FEATURES flag, and if so, it sets | ||
the flag to true when there is a `enableoptionalfeatures` query parameter. | ||
*/ | ||
contentFor: function(name) { | ||
if (name === "vendor-prefix") { | ||
var array = [ | ||
"<!-- injected by lib/enable-optional-features-via-url -->", | ||
"window.EmberENV = window.EmberENV || {};", | ||
"if (typeof window.EmberENV.ENABLE_OPTIONAL_FEATURES === 'undefined') {", | ||
" window.EmberENV.ENABLE_OPTIONAL_FEATURES = window.location.search.indexOf('enableoptionalfeatures') !== -1;", | ||
"}" | ||
]; | ||
|
||
return array.join('\n'); | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "enable-optional-features-via-url", | ||
"keywords": [ | ||
"ember-addon" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters