tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

bug396519_window.xhtml (4318B)


      1 <?xml version="1.0"?>
      2 
      3 <!-- This Source Code Form is subject to the terms of the Mozilla Public
      4   - License, v. 2.0. If a copy of the MPL was not distributed with this
      5   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
      6 
      7 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
      8 
      9 <window id="396519Test"
     10        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
     11        width="600"
     12        height="600"
     13        onload="runTest();"
     14        title="396519 test">
     15 
     16  <script src="chrome://mochikit/content/chrome-harness.js" />
     17  <script type="application/javascript" src="docshell_helpers.js" />
     18  <script type="application/javascript"><![CDATA[
     19    Services.prefs.setBoolPref("browser.navigation.requireUserInteraction", false);
     20 
     21    var gTestCount = 0;
     22 
     23    async function navigateAndTest(params, expected) {
     24      await promisePageNavigation(params);
     25      ++gTestCount;
     26      await doTest(expected);
     27    }
     28 
     29    async function doTest(expected) {
     30      function check(testCount, expected) {
     31        let history;
     32        if (SpecialPowers.Services.appinfo.sessionHistoryInParent) {
     33          history = this.browsingContext.sessionHistory;
     34        } else {
     35          history = this.content.browsingContext.childSessionHistory.legacySHistory;
     36        }
     37        if (history.count == expected.length) {
     38          for (let i = 0; i < history.count; i++) {
     39            var shEntry = history.getEntryAtIndex(i).
     40                            QueryInterface(Ci.nsISHEntry);
     41            is(shEntry.isInBFCache, expected[i], `BFCache for shentry[${i}], test ${testCount}`);
     42          }
     43 
     44          // Make sure none of the SHEntries share bfcache entries with one
     45          // another.
     46          for (let i = 0; i < history.count; i++) {
     47            for (let j = 0; j < history.count; j++) {
     48              if (j == i)
     49                continue;
     50 
     51              let shentry1 = history.getEntryAtIndex(i)
     52                                    .QueryInterface(Ci.nsISHEntry);
     53              let shentry2 = history.getEntryAtIndex(j)
     54                                    .QueryInterface(Ci.nsISHEntry);
     55              ok(!shentry1.sharesDocumentWith(shentry2),
     56                 'Test ' + testCount + ': shentry[' + i + "] shouldn't " +
     57                 "share document with shentry[" + j + ']');
     58            }
     59          }
     60        }
     61        else {
     62          is(history.count, expected.length, "Wrong history length in test "+testCount);
     63        }
     64      }
     65 
     66      if (SpecialPowers.Services.appinfo.sessionHistoryInParent) {
     67        check.call(TestWindow.getBrowser(), gTestCount, expected);
     68      } else {
     69        await SpecialPowers.spawn(TestWindow.getBrowser(), [gTestCount, expected], check);
     70      }
     71    }
     72 
     73    async function runTest() {
     74      // Tests 1 + 2:
     75      //  Back/forward between two simple documents. Bfcache will be used.
     76 
     77      var test1Doc = "data:text/html,<html><head><title>test1</title></head>" +
     78                     "<body>test1</body></html>";
     79 
     80      await navigateAndTest({
     81        uri: test1Doc,
     82      }, [false]);
     83 
     84      var test2Doc = test1Doc.replace(/1/,"2");
     85 
     86      await navigateAndTest({
     87        uri: test2Doc,
     88      }, [true, false]);
     89 
     90      await navigateAndTest({
     91        uri: test1Doc,
     92      }, [true, true, false]);
     93 
     94      await navigateAndTest({
     95        uri: test2Doc,
     96      }, [true, true, true, false]);
     97 
     98      await navigateAndTest({
     99        uri: test1Doc,
    100      }, [false, true, true, true, false]);
    101 
    102      await navigateAndTest({
    103        uri: test2Doc,
    104      }, [false, false, true, true, true, false]);
    105 
    106      await navigateAndTest({
    107        back: true,
    108      }, [false, false, true, true, false, true]);
    109 
    110      await navigateAndTest({
    111        forward: true,
    112      }, [false, false, true, true, true, false]);
    113 
    114      await navigateAndTest({
    115        gotoIndex: 1,
    116      }, [false, false, true, true, true, false]);
    117 
    118      await navigateAndTest({
    119        back: true,
    120      }, [false, true, true, true, false, false]);
    121 
    122      await navigateAndTest({
    123        gotoIndex: 5,
    124      }, [false, false, true, true, false, false]);
    125 
    126      Services.prefs.clearUserPref("browser.navigation.requireUserInteraction");
    127      finish();
    128    }
    129  ]]></script>
    130 
    131  <browser type="content" primary="true" flex="1" id="content" remote="true" maychangeremoteness="true" />
    132 </window>