summaryrefslogtreecommitdiffstats
path: root/layout/generic/test/file_bug514732_window.xhtml
blob: 5d7342776fae7970e79e8a4af07689b60056cbeb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>

<window id="514732Test"
        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
        width="600"
        height="600"
        onload="setTimeout(startTests,0);"
        title="bug 514732 test">

  <script type="application/javascript"><![CDATA[
    window.opener = window.arguments[0];
  ]]></script>

  <script type="application/javascript" src="chrome://mochikit/content/chrome-harness.js" />
  <script src="chrome://mochikit/content/tests/SimpleTest/docshell_helpers.js">
  </script>

  <script type="application/javascript"><![CDATA[
  
    // Define the generator-iterator for the tests.
    var tests = testIterator();

    ////
    // Execute the next test in the generator function.
    //
    function nextTest() {
      tests.next();
    }

    ////
    // Generator function for test steps for bug 514732.  The MozScrolledAreaChanged
    // should be fired when a page is restored from the bfcache as though it had
    // reloaded.
    //
    function* testIterator() {
      // Make sure bfcache is on.
      enableBFCache(true);

        
      // Load a wide and tall page, and then another.
      for (var i = 0; i < 2; ++i) {
        doPageNavigation( {
          uri: "data:text/html,<!DOCTYPE html><html>" + 
               "<head><title>bug 514732 bfcache test page " + i + "</title></head>" +
               "<body>" + 
               '<div style="position: absolute; left: 10000px; top: 10000px; width: 500px; height: 500px;">' +
               "</body></html>",
          eventsToListenFor: ["MozScrolledAreaChanged"],
          expectedEvents: [ { type: "MozScrolledAreaChanged" } ],
          onNavComplete: nextTest
        } );
        yield;
      }

      // Navigate back to the first page.  Don't test for width and height
      // yet, just make sure we get an event.
      doPageNavigation( {
        back: true,
        eventsToListenFor: ["MozScrolledAreaChanged"],
        expectedEvents: [ { type: "MozScrolledAreaChanged" } ],
        onNavComplete: nextTest
      } );
      yield;

      // Navigate forth to our wide and tall page, this time testing for
      // width and height on the event.
      doPageNavigation( {
        forward: true,
        eventsToListenFor: ["MozScrolledAreaChanged"],
        expectedEvents: [ { type: "MozScrolledAreaChanged" } ],
        onNavComplete: nextTest
      } );
      yield;

      finish();
    }

    function startTests() {
      // Flush layout in outer and inner documents (in that order), to be sure
      // our TestWindow's initial about:blank document doesn't have any
      // pending reflows. (If we leave these pending reflows un-flushed, then
      // they might happen after we've set up our MozScrolledAreaChanged
      // event-listener; and that would confuse our test logic and lead to
      // timeouts and test-failures.)
      document.documentElement.offsetHeight;
      TestWindow.getDocument().documentElement.offsetHeight;

      // Kick off the first test via the generator-iterator.
      nextTest();
    }
  ]]></script>

  <browser type="content" primary="true" flex="1" id="content" src="about:blank"/>
</window>