diff options
| author | Igor Minar | 2013-04-18 12:50:49 -0700 |
|---|---|---|
| committer | Igor Minar | 2013-04-18 14:34:53 -0700 |
| commit | 5da6b125a7447b4bbabb88b2d82b5634b55c3aea (patch) | |
| tree | d67bb5ce97dbed432b15ed9481f5055416437604 /src/ngScenario/Scenario.js | |
| parent | 695c54c17b3299cd6170c45878b41cb46a577cd2 (diff) | |
| download | angular.js-5da6b125a7447b4bbabb88b2d82b5634b55c3aea.tar.bz2 | |
test(modules): fix module tests which got disabled by ngMobile
When ngMobile was merged in, we accidentaly included angular-scenario.js
in the test file set for modules. Loading this file overrode jasmine's
`it` and `describe` global functions which essentially disabled all of
~200 unit tests for wrapped modules.
This change refactors the code to run the wrapped module tests.
I had to extract browserTrigger from scenario runner in order to achieve
this without code duplication.
Diffstat (limited to 'src/ngScenario/Scenario.js')
| -rw-r--r-- | src/ngScenario/Scenario.js | 96 |
1 files changed, 0 insertions, 96 deletions
diff --git a/src/ngScenario/Scenario.js b/src/ngScenario/Scenario.js index 1ed9d119..f78e3931 100644 --- a/src/ngScenario/Scenario.js +++ b/src/ngScenario/Scenario.js @@ -223,102 +223,6 @@ function callerFile(offset) { }; } -/** - * Triggers a browser event. Attempts to choose the right event if one is - * not specified. - * - * @param {Object} element Either a wrapped jQuery/jqLite node or a DOMElement - * @param {string} type Optional event type. - * @param {Array.<string>=} keys Optional list of pressed keys - * (valid values: 'alt', 'meta', 'shift', 'ctrl') - * @param {number} x Optional x-coordinate for mouse/touch events. - * @param {number} y Optional y-coordinate for mouse/touch events. - */ -function browserTrigger(element, type, keys, x, y) { - if (element && !element.nodeName) element = element[0]; - if (!element) return; - if (!type) { - type = { - 'text': 'change', - 'textarea': 'change', - 'hidden': 'change', - 'password': 'change', - 'button': 'click', - 'submit': 'click', - 'reset': 'click', - 'image': 'click', - 'checkbox': 'click', - 'radio': 'click', - 'select-one': 'change', - 'select-multiple': 'change' - }[lowercase(element.type)] || 'click'; - } - if (lowercase(nodeName_(element)) == 'option') { - element.parentNode.value = element.value; - element = element.parentNode; - type = 'change'; - } - - keys = keys || []; - function pressed(key) { - return indexOf(keys, key) !== -1; - } - - if (msie < 9) { - switch(element.type) { - case 'radio': - case 'checkbox': - element.checked = !element.checked; - break; - } - // WTF!!! Error: Unspecified error. - // Don't know why, but some elements when detached seem to be in inconsistent state and - // calling .fireEvent() on them will result in very unhelpful error (Error: Unspecified error) - // forcing the browser to compute the element position (by reading its CSS) - // puts the element in consistent state. - element.style.posLeft; - - // TODO(vojta): create event objects with pressed keys to get it working on IE<9 - var ret = element.fireEvent('on' + type); - if (lowercase(element.type) == 'submit') { - while(element) { - if (lowercase(element.nodeName) == 'form') { - element.fireEvent('onsubmit'); - break; - } - element = element.parentNode; - } - } - return ret; - } else { - var evnt = document.createEvent('MouseEvents'), - originalPreventDefault = evnt.preventDefault, - iframe = _jQuery('#application iframe')[0], - appWindow = iframe ? iframe.contentWindow : window, - fakeProcessDefault = true, - finalProcessDefault, - angular = appWindow.angular || {}; - - // igor: temporary fix for https://bugzilla.mozilla.org/show_bug.cgi?id=684208 - angular['ff-684208-preventDefault'] = false; - evnt.preventDefault = function() { - fakeProcessDefault = false; - return originalPreventDefault.apply(evnt, arguments); - }; - - x = x || 0; - y = y || 0; - evnt.initMouseEvent(type, true, true, window, 0, x, y, x, y, pressed('ctrl'), pressed('alt'), - pressed('shift'), pressed('meta'), 0, element); - - element.dispatchEvent(evnt); - finalProcessDefault = !(angular['ff-684208-preventDefault'] || !fakeProcessDefault); - - delete angular['ff-684208-preventDefault']; - - return finalProcessDefault; - } -} /** * Don't use the jQuery trigger method since it works incorrectly. |
