Tue, 06 Jan 2015 21:39:09 +0100
Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
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> |