Attachment #783470: Propagate the sandbox flags through in nsObjectLoadingContent. for bug #886262

View | Details | Raw Unified | Return to bug 886262
Collapse All | Expand All

(-)a/content/base/src/nsObjectLoadingContent.cpp (+3 lines)
Line     Link Here 
 Lines 2108-2123   nsObjectLoadingContent::LoadObject(bool Link Here 
2108
      nsCOMPtr<nsIDocShell> docShell;
2108
      nsCOMPtr<nsIDocShell> docShell;
2109
      rv = mFrameLoader->GetDocShell(getter_AddRefs(docShell));
2109
      rv = mFrameLoader->GetDocShell(getter_AddRefs(docShell));
2110
      if (NS_FAILED(rv)) {
2110
      if (NS_FAILED(rv)) {
2111
        NS_NOTREACHED("Could not get DocShell from mFrameLoader?");
2111
        NS_NOTREACHED("Could not get DocShell from mFrameLoader?");
2112
        mType = eType_Null;
2112
        mType = eType_Null;
2113
        break;
2113
        break;
2114
      }
2114
      }
2115
2115
2116
      // Make sure this docshell has our sandbox flags
2117
      docShell->SetSandboxFlags(doc->GetSandboxFlags());
2118
2116
      nsCOMPtr<nsIInterfaceRequestor> req(do_QueryInterface(docShell));
2119
      nsCOMPtr<nsIInterfaceRequestor> req(do_QueryInterface(docShell));
2117
      NS_ASSERTION(req, "Docshell must be an ifreq");
2120
      NS_ASSERTION(req, "Docshell must be an ifreq");
2118
2121
2119
      nsCOMPtr<nsIURILoader>
2122
      nsCOMPtr<nsIURILoader>
2120
        uriLoader(do_GetService(NS_URI_LOADER_CONTRACTID, &rv));
2123
        uriLoader(do_GetService(NS_URI_LOADER_CONTRACTID, &rv));
2121
      if (NS_FAILED(rv)) {
2124
      if (NS_FAILED(rv)) {
2122
        NS_NOTREACHED("Failed to get uriLoader service");
2125
        NS_NOTREACHED("Failed to get uriLoader service");
2123
        mType = eType_Null;
2126
        mType = eType_Null;
(-)a/content/base/test/Makefile.in (+1 lines)
Line     Link Here 
 Lines 237-252   MOCHITEST_FILES_A = \ Link Here 
237
		bug282547.sjs \
237
		bug282547.sjs \
238
		test_domparser_null_char.html \
238
		test_domparser_null_char.html \
239
		test_bug811701.html \
239
		test_bug811701.html \
240
		test_bug811701.xhtml \
240
		test_bug811701.xhtml \
241
		test_bug820909.html \
241
		test_bug820909.html \
242
		test_bug704063.html \
242
		test_bug704063.html \
243
		test_bug894874.html \
243
		test_bug894874.html \
244
		test_bug895974.html \
244
		test_bug895974.html \
245
		test_bug886262.html \
245
		$(NULL)
246
		$(NULL)
246
247
247
MOCHITEST_FILES_B = \
248
MOCHITEST_FILES_B = \
248
		test_bug459424.html \
249
		test_bug459424.html \
249
		bug461735-redirect1.sjs \
250
		bug461735-redirect1.sjs \
250
		bug461735-redirect2.sjs \
251
		bug461735-redirect2.sjs \
251
		bug461735-post-redirect.js \
252
		bug461735-post-redirect.js \
252
		test_bug513194.html \
253
		test_bug513194.html \
(-)a/content/base/test/test_bug886262.html (+62 lines)
Line     Link Here 
Line 0    Link Here 
1
<!DOCTYPE HTML>
2
<html>
3
<!--
4
https://bugzilla.mozilla.org/show_bug.cgi?id=886262
5
-->
6
<head>
7
  <meta charset="utf-8">
8
  <title>Test for Bug 886262</title>
9
  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
10
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
11
  <script type="application/javascript">
12
13
  /** Test for Bug 886262 **/
14
  SimpleTest.waitForExplicitFinish();
15
  var gotSet1 = false;
16
  var gotSet2 = false;
17
  var gotSet3 = false;
18
19
  var gotMessage = false, gotLoad = false;
20
21
  window.onmessage = function(e) {
22
    ok(e.data.ran, "Sandboxed allow-scripts iframe should run script");
23
    ok(e.data.gotSet,
24
       "Sandboxed allow-scripts iframe's kid should not be able to set props on its parent");
25
    ok(!gotSet2,
26
       "Sandboxed allow-scripts iframe should not be able to set props on us");
27
    if (gotLoad) {
28
      SimpleTest.finish();
29
    } else {
30
      gotMessage = true;
31
    }
32
  }
33
  addLoadEvent(function() {
34
    ok(!gotSet1, "Sandboxed iframe should not be able to set props on us");
35
    ok(!frames[0][0].scriptRan, "Sandboxed iframe should not run script");
36
37
    ok(gotSet3,
38
       "Sandboxed allow-scripts same-origin iframe should be able to set " +
39
       "props on us");
40
    ok(frames[2][0].scriptRan,
41
       "Sandboxed allow-scripts same-origin iframe should run script");
42
    if (gotMessage) {
43
      SimpleTest.finish();
44
    } else {
45
      gotLoad = true;
46
    }
47
  });
48
  </script>
49
</head>
50
<body>
51
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=886262">Mozilla Bug 886262</a>
52
<p id="display"></p>
53
<div id="content" style="display: none">
54
  <iframe sandbox="allow-same-origin" src="data:text/html,<object%20data='data:text/html,<script>var scriptRan = true;</script><script>parent.parent.gotSet1 = true</script>'></object>"></iframe>
55
  <iframe sandbox="allow-scripts"
56
  src="data:text/html,<script>var gotSet = false;</script><object%20data='data:text/html,<script>var scriptRan = true;</script><script>parent.gotSet = true</script>'></object><script>window.onload = function() {parent.postMessage({ 'ran': frames[0].scriptRan, 'gotSet': window.gotSet }, '*'); }</script>"></iframe>
57
  <iframe sandbox="allow-scripts allow-same-origin" src="data:text/html,<object%20data='data:text/html,<script>var scriptRan = true;</script><script>parent.parent.gotSet3 = true</script>'></object>"></iframe>
58
</div>
59
<pre id="test">
60
</pre>
61
</body>
62
</html>

Return to bug 886262