From 33add3b0335bb97266dc52dcb9569baadca642e8 Mon Sep 17 00:00:00 2001 From: John Bender Date: Tue, 13 Dec 2011 17:39:34 -0800 Subject: [PATCH] test cross domain check helper --- tests/unit/navigation/navigation_helpers.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/unit/navigation/navigation_helpers.js b/tests/unit/navigation/navigation_helpers.js index 88533b76..7fd5f7ce 100644 --- a/tests/unit/navigation/navigation_helpers.js +++ b/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); \ No newline at end of file