toolkit/components/viewsource/test/test_428653.xul

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 <?xml-stylesheet href="chrome://global/skin/" type="text/css"?> 
     2 <?xml-stylesheet
     3   href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
     5 <window title="View Source Test (bug 428653)"
     6         xmlns:html="http://www.w3.org/1999/xhtml"
     7         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
     9   <script type="application/javascript"
    10    src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
    12   <html:body/>
    14   <browser id="content" type="content-primary" name="content" src="about:blank" flex="1"
    15            disablehistory="true" context="viewSourceContextMenu"/>
    17   <script type="application/javascript">
    18   <![CDATA[
    19   /*
    20   Test that we can't call the content browser's document.open() either via
    21   wrappedJSObject (SafeJSObjectWrapper) or not.
    22   */
    23   SimpleTest.waitForExplicitFinish();
    25   addLoadEvent(function testDocumentOpen() {
    26     var browser = document.getElementById("content");
    27     ok(browser, "got browser");
    28     var doc = browser.contentDocument;
    29     ok(doc, "got content document");
    31     var opened = false;
    32     try {
    33       doc.open("text/html", "replace");
    34       opened = true;
    35     } catch (e) {
    36       is(e.name, "SecurityError", "Unxpected exception")
    37     }
    38     is(opened, false, "Shouldn't have opened document");
    40     try {
    41       doc.wrappedJSObject.open("text/html", "replace");
    42       opened = true;
    43     } catch (e) {
    44       is(e.name, "SecurityError",
    45          "Unxpected exception via wrappedJSObject")
    46     }
    47     is(opened, false, "Shouldn't have opened document via wrappedJSObject");
    49     SimpleTest.finish();
    50   });
    51   ]]>
    52   </script>
    53 </window>

mercurial