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