caps/tests/mochitest/test_app_principal_equality.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/caps/tests/mochitest/test_app_principal_equality.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,68 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=777467
     1.8 +-->
     1.9 +<head>
    1.10 +  <meta charset="utf-8">
    1.11 +  <title>Test app principal's equality</title>
    1.12 +  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.13 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    1.14 +</head>
    1.15 +<body>
    1.16 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=777467">Mozilla Bug 777467</a>
    1.17 +<p id="display"></p>
    1.18 +<script>
    1.19 +  // Initialization.
    1.20 +  SpecialPowers.addPermission("browser", true, document);
    1.21 +  SpecialPowers.addPermission("embed-apps", true, document);
    1.22 +
    1.23 +  SpecialPowers.setBoolPref('dom.mozBrowserFramesEnabled', true);
    1.24 +  SpecialPowers.setBoolPref("dom.ipc.browser_frames.oop_by_default", false);
    1.25 +</script>
    1.26 +<div id="content" style="display: none;">
    1.27 +  <iframe src="error404"></iframe>
    1.28 +  <iframe mozbrowser src="error404"></iframe>
    1.29 +  <iframe mozapp="http://example.org/manifest.webapp" mozbrowser src="error404"></iframe>
    1.30 +</div>
    1.31 +<pre id="test">
    1.32 +<script type="application/javascript">
    1.33 +
    1.34 +/** Test for app principal's equality **/
    1.35 +
    1.36 +SimpleTest.waitForExplicitFinish();
    1.37 +
    1.38 +function canAccessDocument(win) {
    1.39 +  var result = true;
    1.40 +  try {
    1.41 +    win.document;
    1.42 +  } catch(e) {
    1.43 +    result = false;
    1.44 +  }
    1.45 +  return result;
    1.46 +}
    1.47 +
    1.48 +addLoadEvent(function() {
    1.49 +  // Test the witness frame (we can access same-origin frame).
    1.50 +  is(canAccessDocument(frames[0]), true,
    1.51 +     "should be able to access the first frame");
    1.52 +
    1.53 +  // Test different app/browserElement frames.
    1.54 +  for (var i=1; i<frames.length; ++i) {
    1.55 +    is(canAccessDocument(frames[i]), false,
    1.56 +       "should not be able to access the other frames");
    1.57 +  }
    1.58 +
    1.59 +  // Cleanup.
    1.60 +  SpecialPowers.clearUserPref('dom.mozBrowserFramesEnabled');
    1.61 +  SpecialPowers.clearUserPref('dom.ipc.browser_frames.oop_by_default');
    1.62 +  SpecialPowers.removePermission("browser", window.document);
    1.63 +  SpecialPowers.removePermission("embed-apps", window.document);
    1.64 +
    1.65 +  SimpleTest.finish();
    1.66 +});
    1.67 +
    1.68 +</script>
    1.69 +</pre>
    1.70 +</body>
    1.71 +</html>

mercurial