toolkit/components/viewsource/test/test_428653.xul

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/components/viewsource/test/test_428653.xul	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,53 @@
     1.4 +<?xml-stylesheet href="chrome://global/skin/" type="text/css"?> 
     1.5 +<?xml-stylesheet
     1.6 +  href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
     1.7 +
     1.8 +<window title="View Source Test (bug 428653)"
     1.9 +        xmlns:html="http://www.w3.org/1999/xhtml"
    1.10 +        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
    1.11 +
    1.12 +  <script type="application/javascript"
    1.13 +   src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
    1.14 +   
    1.15 +  <html:body/>
    1.16 +
    1.17 +  <browser id="content" type="content-primary" name="content" src="about:blank" flex="1"
    1.18 +           disablehistory="true" context="viewSourceContextMenu"/>
    1.19 +
    1.20 +  <script type="application/javascript">
    1.21 +  <![CDATA[
    1.22 +  /*
    1.23 +  Test that we can't call the content browser's document.open() either via
    1.24 +  wrappedJSObject (SafeJSObjectWrapper) or not.
    1.25 +  */
    1.26 +  SimpleTest.waitForExplicitFinish();
    1.27 +  
    1.28 +  addLoadEvent(function testDocumentOpen() {
    1.29 +    var browser = document.getElementById("content");
    1.30 +    ok(browser, "got browser");
    1.31 +    var doc = browser.contentDocument;
    1.32 +    ok(doc, "got content document");
    1.33 +
    1.34 +    var opened = false;
    1.35 +    try {
    1.36 +      doc.open("text/html", "replace");
    1.37 +      opened = true;
    1.38 +    } catch (e) {
    1.39 +      is(e.name, "SecurityError", "Unxpected exception")
    1.40 +    }
    1.41 +    is(opened, false, "Shouldn't have opened document");
    1.42 +
    1.43 +    try {
    1.44 +      doc.wrappedJSObject.open("text/html", "replace");
    1.45 +      opened = true;
    1.46 +    } catch (e) {
    1.47 +      is(e.name, "SecurityError",
    1.48 +         "Unxpected exception via wrappedJSObject")
    1.49 +    }
    1.50 +    is(opened, false, "Shouldn't have opened document via wrappedJSObject");
    1.51 +
    1.52 +    SimpleTest.finish();
    1.53 +  });
    1.54 +  ]]>
    1.55 +  </script>
    1.56 +</window>

mercurial