Permalink
Browse files

test cross domain check helper

  • Loading branch information...
1 parent 36c9d3a commit 33add3b0335bb97266dc52dcb9569baadca642e8 @johnbender committed Dec 14, 2011
Showing with 15 additions and 0 deletions.
  1. +15 −0 tests/unit/navigation/navigation_helpers.js
@@ -215,4 +215,19 @@
same( $.mobile.path.cleanHash( "#anything/atall?akjfdjjf" ), "anything/atall", "removes query param");
same( $.mobile.path.cleanHash( "#nothing/atall" ), "nothing/atall", "removes query param");
});
+
+ test( "path.isPermittedCrossDomainRequest", function() {
+ var fileDocUrl = $.mobile.path.parseUrl( "file://foo" );
+
+ $.mobile.allowCrossDomainPages = false;
+ same( $.mobile.path.isPermittedCrossDomainRequest( "foo", "bar"), false, "always false from the setting");
+
+
+ $.mobile.allowCrossDomainPages = true;
+ // test the two states of the file protocol logic
+ same( $.mobile.path.isPermittedCrossDomainRequest( fileDocUrl, "http://bar.com/foo"), true, "external url from file protocol succeeds");
+
+ same( $.mobile.path.isPermittedCrossDomainRequest( fileDocUrl, "file://foo"), false, "two file protocol urls fail");
+
+ });
})(jQuery);

0 comments on commit 33add3b

Please sign in to comment.