Commit 1033bfa2 authored by Sebastian Hengst's avatar Sebastian Hengst
Browse files

Backed out changeset 4eb1a4c1fdb1 (bug 1404910) for failing...

Backed out changeset 4eb1a4c1fdb1 (bug 1404910) for failing dom/base/test/test_window_cross_origin_props.html with e10s (runs on Windows 7 debug). r=backout a=backout on a CLOSED TREE

MozReview-Commit-ID: 2FATIBGSlEg
parent 57b1e211
Loading
Loading
Loading
Loading
+8 −7
Original line number Diff line number Diff line
@@ -1666,17 +1666,18 @@ WebSocketImpl::Init(JSContext* aCx,
      nsCOMPtr<nsPIDOMWindowInner> innerWindow;

      while (true) {
        if (principal && !principal->GetIsNullPrincipal()) {
        if (principal) {
          bool isNullPrincipal = true;
          isNullPrincipal = principal->GetIsNullPrincipal();
          if (isNullPrincipal || nsContentUtils::IsSystemPrincipal(principal)) {
            break;
          }
        }

        if (!innerWindow) {
          innerWindow = do_QueryInterface(globalObject);
          if (!innerWindow) {
            // If we are in a XPConnect sandbox or in a JS component,
            // innerWindow will be null. There is nothing on top of this to be
            // considered.
            break;
          if (NS_WARN_IF(!innerWindow)) {
            return NS_ERROR_DOM_SECURITY_ERR;
          }
        }

+0 −62
Original line number Diff line number Diff line
<html><body>
<iframe id="frame" sandbox="allow-scripts allow-popups"></iframe>
<script type="application/javascript;version=1.8">
onmessage = function(e) {
  parent.postMessage(e.data, '*');
}

var ifr = document.getElementById('frame');

if (location.search == '?nested') {
  var url = new URL(location);
  url.search = "";
  ifr.src = url.href;
} else if (location.search == '?popup') {
  var url = new URL(location);
  url.search = "?opener";

  ifr.srcdoc = "<html><script>" +
    "window.open('" + url.href + "', 'foobar');" +
    "onmessage = function(e) { " +
    "  parent.postMessage(e.data, '*'); " +
    "}" +
  "</scr" + "ipt></html>";
} else if (location.search == '?opener') {
  try{
    var socket = new WebSocket('ws://mochi.test:8888/tests/dom/base/test/file_websocket_basic');
    socket.onerror = function(e) {
      opener.postMessage('WS onerror', '*');
    };
    socket.onopen = function(event) {
      opener.postMessage('WS onopen', '*');
    };
  } catch(e) {
    if (e.name == 'SecurityError') {
      opener.postMessage('WS Throws!', '*');
    } else {
      opener.postMessage('WS Throws something else!', '*');
    }
  }
} else {
  ifr.srcdoc = `
  <html><script>
  try{
    var socket = new WebSocket('ws://mochi.test:8888/tests/dom/base/test/file_websocket_basic');
    socket.onerror = function(e) {
      parent.postMessage('WS onerror', '*');
    };
    socket.onopen = function(event) {
      parent.postMessage('WS onopen', '*');
    };
  } catch(e) {
    if (e.name == 'SecurityError') {
      parent.postMessage('WS Throws!', '*');
    } else {
      parent.postMessage('WS Throws something else!', '*');
    }
  }
  </scr`+`ipt>
  </html>`;
}
</script>
</body></html>
+0 −3
Original line number Diff line number Diff line
@@ -805,9 +805,6 @@ skip-if = toolkit == 'android'
skip-if = toolkit == 'android'
[test_websocket_permessage_deflate.html]
skip-if = toolkit == 'android'
[test_webSocket_sandbox.html]
skip-if = toolkit == 'android'
support-files = iframe_webSocket_sandbox.html
[test_websocket1.html]
skip-if = toolkit == 'android'
[test_websocket2.html]
+0 −34
Original line number Diff line number Diff line
<!DOCTYPE HTML>
<html>
<head>
  <title>Bug 1252751</title>
  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<div id="container"></div>
<iframe id="frame"></iframe>
<script type="application/javascript;version=1.8">
var urls = [ "https://example.com/tests/dom/base/test/iframe_webSocket_sandbox.html",
             "https://example.com/tests/dom/base/test/iframe_webSocket_sandbox.html?nested",
             "https://example.com/tests/dom/base/test/iframe_webSocket_sandbox.html?popup" ];

onmessage = function(e) {
  is(e.data, "WS Throws!", "ws://URI cannot be used by a https iframe");
  runTest();
}

function runTest() {
  if (!urls.length) {
    SimpleTest.finish();
    return;
  }

  document.getElementById("frame").src = urls.shift();
}

SimpleTest.waitForExplicitFinish();
runTest();
</script>
</body>
</html>