<!DOCTYPE HTML>
<html>
<head> <meta charset="utf-8"> </head>
<script type="text/javascript">
  function ok(result, desc) {
    window.parent.postMessage({ok: result, desc}, "*");
  }
  function doStuff() {
    var beforePrincipal = SpecialPowers.wrap(document).nodePrincipal;
    document.open();
    document.write("rewritten sandboxed document");
    document.close();
    var afterPrincipal = SpecialPowers.wrap(document).nodePrincipal;
    ok(beforePrincipal.equals(afterPrincipal),
       "document.write() does not change underlying principal");
  }
</script>
<body onLoad='doStuff();'>
  sandboxed with allow-scripts
</body>
</html>
