diff --git a/test/ng/directive/formSpec.js b/test/ng/directive/formSpec.js index fa047480594f..96855f52fc6d 100644 --- a/test/ng/directive/formSpec.js +++ b/test/ng/directive/formSpec.js @@ -128,17 +128,25 @@ describe('form', function() { describe('preventing default submission', function() { it('should prevent form submission', function() { - var startingUrl = '' + window.location; - doc = jqLite('
'); + var nextTurn = false, + reloadPrevented; + + doc = jqLite('
'); $compile(doc)(scope); + doc.bind('submit', function(e) { + reloadPrevented = e.defaultPrevented; + }); + browserTrigger(doc.find('input')); - waitsFor( - function() { return true; }, - 'let browser breath, so that the form submission can manifest itself', 10); + + // let the browser process all events (and potentially reload the page) + setTimeout(function() { nextTurn = true;}); + + waitsFor(function() { return nextTurn; }); runs(function() { - expect('' + window.location).toEqual(startingUrl); + expect(reloadPrevented).toBe(true); }); });