dom/tests/mochitest/general/file_frameElementWrapping.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 <html>
michael@0 2 <script>
michael@0 3 function check(elt, expectAccess, prop) {
michael@0 4 var access = false;
michael@0 5 try {
michael@0 6 elt[prop];
michael@0 7 access = true;
michael@0 8 }
michael@0 9 catch (e) {}
michael@0 10 return access === expectAccess;
michael@0 11 }
michael@0 12
michael@0 13 function sendMessage(success, sameOrigin, prop) {
michael@0 14 var result = success ? 'PASS' : 'FAIL';
michael@0 15 var message;
michael@0 16 if (sameOrigin)
michael@0 17 message = 'Can access |' + prop + '| if same origin';
michael@0 18 else
michael@0 19 message = 'Cannot access |' + prop + '| if not same origin';
michael@0 20 parent.postMessage(result + ',' + message, '*');
michael@0 21 }
michael@0 22
michael@0 23 var sameOrigin = location.host !== 'example.org';
michael@0 24 var pass = check(frameElement, sameOrigin, 'src');
michael@0 25 if (!pass) {
michael@0 26 sendMessage(false, sameOrigin, 'src');
michael@0 27 } else {
michael@0 28 pass = check(parent.location, sameOrigin, 'href');
michael@0 29 sendMessage(pass, sameOrigin, 'href');
michael@0 30 }
michael@0 31 </script>
michael@0 32 </html>

mercurial