| <?xml version="1.0" encoding="UTF-8"?> |
| <!-- |
| Licensed to the Apache Software Foundation (ASF) under one |
| or more contributor license agreements. See the NOTICE file |
| distributed with this work for additional information |
| regarding copyright ownership. The ASF licenses this file |
| to you under the Apache License, Version 2.0 (the |
| "License"); you may not use this file except in compliance |
| with the License. You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, |
| software distributed under the License is distributed on an |
| "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| KIND, either express or implied. See the License for the |
| specific language governing permissions and limitations |
| under the License. |
| --> |
| <Module> |
| <ModulePrefs |
| title="Test Gadget and Container Domain Configuration" |
| description="Tests Gadget and Container domain configuration by trying to access container page information from within a gadget" |
| > |
| </ModulePrefs> |
| <Content type="html"><![CDATA[ |
| <html> |
| <head> |
| <link href='http://fonts.googleapis.com/css?family=Lora|Istok+Web:700' rel='stylesheet' type='text/css'/> |
| <link rel="stylesheet" href="http://pivotal.github.com/jasmine/css/docco.css"/> |
| <link rel="stylesheet" href="http://pivotal.github.com/jasmine/css/jasmine_docco-1.3.1.css"/> |
| <link rel="stylesheet" href="http://pivotal.github.com/jasmine/lib/jasmine-1.3.1/jasmine.css"/> |
| <style type="text/css"> |
| body { |
| margin: 0; |
| overflow: auto; |
| } |
| .exceptions { |
| display: none; |
| } |
| #HTMLReporter .stackTrace { |
| max-height: 5em; |
| } |
| </style> |
| <script src="http://pivotal.github.com/jasmine/lib/jasmine-1.3.1/jasmine.js"></script> |
| <script src="http://pivotal.github.com/jasmine/lib/jasmine-1.3.1/jasmine-html.js"></script> |
| |
| <!-- Begin Tests --> |
| <script type="text/javascript"> |
| describe("This gadget", function() { |
| it("is rendering over https", function() { |
| expect(window.location.protocol).toMatch(/^https/); |
| }); |
| |
| it("is rendering on a locked domain", function() { |
| expect(gadgets.config.get()['core.io'].proxyUrl).not.toContain('%host%'); |
| }); |
| |
| var undef, |
| parentLoc = undef; |
| it("cannot access the parent window", function() { |
| try { |
| parentLoc = window.parent.location.href; |
| } catch (ignore) {} |
| expect(parentLoc).toBeUndefined(); |
| }); |
| |
| if (parentLoc == undef) { |
| it("cannot access the parent window by lowering its domain", function() { |
| var parts = document.domain.split('.'), |
| undef; |
| parts.shift(); |
| while(parts.length > 1) { |
| document.domain = parts.join('.'); |
| |
| var parentLoc = undef; |
| try { |
| parentLoc = window.parent.location.href; |
| } catch (ignore) {} |
| expect(parentLoc).toBeUndefined(); |
| parts.shift(); |
| } |
| }); |
| } |
| }); |
| </script> |
| |
| <!-- End Tests --> |
| <script type="text/javascript"> |
| gadgets.util.registerOnLoadHandler(function go() { |
| // The links jasmine generates in the report break gadgets. |
| var orig = jasmine.Runner.prototype.finishCallback; |
| jasmine.Runner.prototype.finishCallback = function() { |
| orig.call(this); |
| var links = document.body.getElementsByTagName('a'); |
| for (var i = 0; i < links.length; i++) { |
| links[i].href = 'javascript: void 0;'; |
| } |
| }; |
| |
| var jasmineEnv = jasmine.getEnv(), |
| htmlReporter = new jasmine.HtmlReporter(); |
| jasmineEnv.addReporter(htmlReporter); |
| jasmineEnv.specFilter = function(spec) { |
| return htmlReporter.specFilter(spec); |
| }; |
| jasmineEnv.execute(); |
| }); |
| </script> |
| </head> |
| <body></body> |
| </html> |
| ]]></Content> |
| </Module> |