diff --git a/server/camlistored/ui/navigator.js b/server/camlistored/ui/navigator.js index 19bb3adb1..84ea7823d 100644 --- a/server/camlistored/ui/navigator.js +++ b/server/camlistored/ui/navigator.js @@ -16,6 +16,7 @@ limitations under the License. goog.provide('cam.Navigator'); +goog.require('cam.object'); goog.require('goog.Uri'); // Navigator intercepts various types of browser navgiations and gives its client an opportunity to decide whether the navigation should be handled with JavaScript or not. @@ -75,10 +76,10 @@ cam.Navigator.prototype.onDidNavigate = function() {}; // @return boolean Whether the navigation was handled locally. cam.Navigator.prototype.navigate = function(url) { if (this.dispatchImpl_(url, true)) { - return false; + return true; } this.location_.href = url.toString(); - return true; + return false; }; // Handles navigations initiated via clicking a hyperlink. diff --git a/server/camlistored/ui/navigator_test.js b/server/camlistored/ui/navigator_test.js index 4da1c8c64..e8f35750c 100644 --- a/server/camlistored/ui/navigator_test.js +++ b/server/camlistored/ui/navigator_test.js @@ -70,26 +70,29 @@ describe('cam.Navigator', function() { it('#navigate - no handler', function() { // We should do network navigation. navigator.onWillNavigate = function(){}; - navigator.navigate(url); + var handledLocally = navigator.navigate(url); assert.equal(mockLocation.href, url.toString()); assert.equal(mockHistory.states.length, 1); + assert.equal(handledLocally, false); }); it('#navigate - handler returns false', function() { // Both handlers should get called, we should do network navigation. - navigator.navigate(url); + var handledLocally = navigator.navigate(url); assert.equal(handler.lastURL, url); assert.equal(mockLocation.href, url.toString()); assert.equal(mockHistory.states.length, 1); + assert.equal(handledLocally, false); }); it('#navigate - handler returns true', function() { // Both handlers should get called, we should do pushState() navigation. handler.returnsTrue = true; - navigator.navigate(url); + var handledLocally = navigator.navigate(url); assert.equal(handler.lastURL, url); assert.equal(mockLocation.href, ''); assert.deepEqual(mockHistory.states, [{state:{}, url:''}, {state:{}, url:url.toString()}]); + assert.equal(handledLocally, true); }); it('#handleClick_ - handled', function() {