diff --git a/platform/features/pages/src/IFrameController.js b/platform/features/pages/src/EmbeddedPageController.js similarity index 73% rename from platform/features/pages/src/IFrameController.js rename to platform/features/pages/src/EmbeddedPageController.js index 94f78d47e7..31ce5c69e3 100644 --- a/platform/features/pages/src/IFrameController.js +++ b/platform/features/pages/src/EmbeddedPageController.js @@ -5,7 +5,7 @@ define( function () { "use strict"; - function Controller($sce) { + function EmbeddedPageController($sce) { return { trust: function (url) { return $sce.trustAsResourceUrl(url); @@ -13,7 +13,7 @@ define( }; } - return Controller; + return EmbeddedPageController; } ); \ No newline at end of file diff --git a/platform/features/pages/test/EmbeddedPageControllerSpec.js b/platform/features/pages/test/EmbeddedPageControllerSpec.js new file mode 100644 index 0000000000..ae2d572b30 --- /dev/null +++ b/platform/features/pages/test/EmbeddedPageControllerSpec.js @@ -0,0 +1,37 @@ +/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/ + +define( + ["../src/EmbeddedPageController"], + function (EmbeddedPageController) { + "use strict"; + + describe("The controller for embedded pages", function () { + var mockSCE, + controller; + + beforeEach(function () { + mockSCE = jasmine.createSpyObj( + '$sce', + ["trustAsResourceUrl"] + ); + + mockSCE.trustAsResourceUrl.andCallFake(function (v) { + return v; + }); + + controller = new EmbeddedPageController(mockSCE) + }); + + it("allows URLs to be marked as trusted", function () { + var testURL = "http://www.nasa.gov"; + + expect(controller.trust(testURL)) + .toEqual(testURL); + + expect(mockSCE.trustAsResourceUrl) + .toHaveBeenCalledWith(testURL); + }); + + }); + } +); diff --git a/platform/features/pages/test/suite.json b/platform/features/pages/test/suite.json new file mode 100644 index 0000000000..0d0efc8302 --- /dev/null +++ b/platform/features/pages/test/suite.json @@ -0,0 +1,3 @@ +[ + "EmbeddedPageController" +] \ No newline at end of file