docshell/test/chrome/bug582176_window.xul

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/docshell/test/chrome/bug582176_window.xul	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,94 @@
     1.4 +<?xml version="1.0"?>
     1.5 +<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
     1.6 +
     1.7 +<window id="303267Test"
     1.8 +        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
     1.9 +        width="600"
    1.10 +        height="600"
    1.11 +        onload="nextTestAsync();"
    1.12 +        title="bug 582176 test">
    1.13 +
    1.14 +  <script type="text/javascript"
    1.15 +          src="chrome://mochikit/content/tests/SimpleTest/specialpowersAPI.js"/>
    1.16 +  <script type="text/javascript"
    1.17 +          src="chrome://mochikit/content/tests/SimpleTest/SpecialPowersObserverAPI.js"/>
    1.18 +  <script type="text/javascript"
    1.19 +          src="chrome://mochikit/content/tests/SimpleTest/ChromePowers.js"/>
    1.20 +  <script type="application/javascript" src= "chrome://mochikit/content/chrome-harness.js" />
    1.21 +  <script type="application/javascript" src="docshell_helpers.js" />
    1.22 +  <script type="application/javascript"><![CDATA[
    1.23 +  
    1.24 +    // Define the generator-iterator for the tests.
    1.25 +    var tests = testIterator();
    1.26 +
    1.27 +    ////
    1.28 +    // Execute the next test in the generator function.
    1.29 +    //
    1.30 +    function nextTestAsync() {
    1.31 +      SimpleTest.executeSoon(tests.next.bind(tests));
    1.32 +    }
    1.33 +
    1.34 +    ////
    1.35 +    // Generator function for test steps for bug 582176:
    1.36 +    // Description goes here.
    1.37 +    //
    1.38 +    function testIterator()
    1.39 +    {
    1.40 +      var browser = document.getElementById('content');
    1.41 +      browser.addEventListener("pageshow", nextTestAsync, true);
    1.42 +
    1.43 +      enableBFCache(true);
    1.44 +
    1.45 +      var notificationCount = 0;
    1.46 +      var observer = {
    1.47 +        observe: function(aSubject, aTopic, aData) {
    1.48 +          is(aSubject, browser.contentWindow,
    1.49 +             "correct subject");
    1.50 +          is(aTopic, "content-document-global-created",
    1.51 +             "correct topic");
    1.52 +          is(aData, "http://mochi.test:8888",
    1.53 +             "correct data");
    1.54 +          notificationCount++;
    1.55 +        }
    1.56 +      };
    1.57 +
    1.58 +      os = Components.classes["@mozilla.org/observer-service;1"].
    1.59 +        getService(Components.interfaces.nsIObserverService);
    1.60 +      os.addObserver(observer, "content-document-global-created", false);
    1.61 +
    1.62 +      browser.loadURI("http://mochi.test:8888/tests/docshell/test/chrome/582176_dummy.html");
    1.63 +      yield undefined;
    1.64 +      is(browser.contentWindow.testVar, undefined,
    1.65 +         "variable unexpectedly there already");
    1.66 +      browser.contentWindow.wrappedJSObject.testVar = 1;
    1.67 +      is(notificationCount, 1, "Should notify on first navigation");
    1.68 +
    1.69 +      browser.loadURI("http://mochi.test:8888/tests/docshell/test/chrome/582176_dummy.html?2");
    1.70 +      yield undefined;
    1.71 +      is(browser.contentWindow.wrappedJSObject.testVar, undefined,
    1.72 +         "variable should no longer be there");
    1.73 +      is(notificationCount, 2, "Should notify on second navigation");
    1.74 +
    1.75 +      browser.goBack();
    1.76 +      yield undefined;
    1.77 +      is(browser.contentWindow.wrappedJSObject.testVar, 1,
    1.78 +         "variable should still be there");
    1.79 +      is(notificationCount, 2, "Should not notify on back navigation");
    1.80 +
    1.81 +      browser.loadURI("http://mochi.test:8888/tests/docshell/test/chrome/582176_xml.xml");
    1.82 +      yield undefined;
    1.83 +      is(browser.contentDocument.body.textContent, "xslt result",
    1.84 +         "Transform performed successfully");
    1.85 +      is(notificationCount, 3, "Should notify only once on XSLT navigation");
    1.86 +
    1.87 +      os.removeObserver(observer, "content-document-global-created")
    1.88 +
    1.89 +      // Tell the framework the test is finished.  Include the final 'yield' 
    1.90 +      // statement to prevent a StopIteration exception from being thrown.
    1.91 +      finish();
    1.92 +      yield undefined;
    1.93 +    }
    1.94 +    
    1.95 +  ]]></script>
    1.96 +  <browser type="content-primary" flex="1" id="content" src="about:blank"/>
    1.97 +</window>

mercurial