browser/components/sessionstore/test/browser_dynamic_frames.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* Any copyright is dedicated to the Public Domain.
     2  * http://creativecommons.org/publicdomain/zero/1.0/ */
     4 "use strict";
     6 /**
     7  * Ensure that static frames of framesets are serialized but dynamically
     8  * inserted iframes are ignored.
     9  */
    10 add_task(function () {
    11   // This URL has the following frames:
    12   //  + about:mozilla (static)
    13   //  + about:robots (static)
    14   //  + about:rights (dynamic iframe)
    15   const URL = "data:text/html;charset=utf-8," +
    16               "<frameset cols=50%25,50%25><frame src=about%3Amozilla>" +
    17               "<frame src=about%3Arobots></frameset>" +
    18               "<script>var i=document.createElement('iframe');" +
    19               "i.setAttribute('src', 'about%3Arights');" +
    20               "document.body.appendChild(i);</script>";
    22   // Add a new tab with two "static" and one "dynamic" frame.
    23   let tab = gBrowser.addTab(URL);
    24   let browser = tab.linkedBrowser;
    25   yield promiseBrowserLoaded(browser);
    27   SyncHandlers.get(browser).flush();
    28   let {entries} = JSON.parse(ss.getTabState(tab));
    30   // Check URLs.
    31   ok(entries[0].url.startsWith("data:text/html"), "correct root url");
    32   is(entries[0].children[0].url, "about:mozilla", "correct url for 1st frame");
    33   is(entries[0].children[1].url, "about:robots", "correct url for 2nd frame");
    35   // Check the number of children.
    36   is(entries.length, 1, "there is one root entry ...");
    37   is(entries[0].children.length, 2, "... with two child entries");
    39   // Cleanup.
    40   gBrowser.removeTab(tab);
    41 });
    43 /**
    44  * Ensure that iframes created by the network parser are serialized but
    45  * dynamically inserted iframes are ignored. Navigating a subframe should
    46  * create a second root entry that doesn't contain any dynamic children either.
    47  */
    48 add_task(function () {
    49   // This URL has the following frames:
    50   //  + about:mozilla (static iframe)
    51   //  + about:rights (dynamic iframe)
    52   const URL = "data:text/html;charset=utf-8," +
    53               "<iframe name=t src=about%3Amozilla></iframe>" +
    54               "<a id=lnk href=about%3Arobots target=t>clickme</a>" +
    55               "<script>var i=document.createElement('iframe');" +
    56               "i.setAttribute('src', 'about%3Arights');" +
    57               "document.body.appendChild(i);</script>";
    59   // Add a new tab with one "static" and one "dynamic" frame.
    60   let tab = gBrowser.addTab(URL);
    61   let browser = tab.linkedBrowser;
    62   yield promiseBrowserLoaded(browser);
    64   SyncHandlers.get(browser).flush();
    65   let {entries} = JSON.parse(ss.getTabState(tab));
    67   // Check URLs.
    68   ok(entries[0].url.startsWith("data:text/html"), "correct root url");
    69   is(entries[0].children[0].url, "about:mozilla", "correct url for static frame");
    71   // Check the number of children.
    72   is(entries.length, 1, "there is one root entry ...");
    73   is(entries[0].children.length, 1, "... with a single child entry");
    75   // Navigate the subframe.
    76   browser.messageManager.sendAsyncMessage("ss-test:click", {id: "lnk"});
    77   yield promiseBrowserLoaded(browser, false /* don't ignore subframes */);
    79   SyncHandlers.get(browser).flush();
    80   let {entries} = JSON.parse(ss.getTabState(tab));
    82   // Check URLs.
    83   ok(entries[0].url.startsWith("data:text/html"), "correct 1st root url");
    84   ok(entries[1].url.startsWith("data:text/html"), "correct 2nd root url");
    85   is(entries[0].children[0].url, "about:mozilla", "correct url for 1st static frame");
    86   is(entries[1].children[0].url, "about:robots", "correct url for 2ns static frame");
    88   // Check the number of children.
    89   is(entries.length, 2, "there are two root entries ...");
    90   is(entries[0].children.length, 1, "... with a single child entry ...");
    91   is(entries[1].children.length, 1, "... each");
    93   // Cleanup.
    94   gBrowser.removeTab(tab);
    95 });

mercurial