docshell/test/browser/browser_bug941562.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 function test() {
     2   waitForExplicitFinish();
     4   var rootDir = "http://mochi.test:8888/browser/docshell/test/browser/";
     5   gBrowser.selectedTab = gBrowser.addTab(rootDir + "file_bug941562.html");
     6   gBrowser.selectedBrowser.addEventListener("load", afterOpen, true);
     7 }
     9 function afterOpen(event) {
    10   if (event.target != gBrowser.contentDocument) {
    11     return;
    12   }
    14   gBrowser.selectedBrowser.removeEventListener("load", afterOpen, true);
    15   gBrowser.selectedBrowser.addEventListener("load", afterChangeCharset, true);
    17   is(gBrowser.contentDocument.documentElement.textContent.indexOf('\u20AC'), 140, "Parent doc should be windows-1252 initially");
    19   is(gBrowser.contentDocument.getElementsByTagName("iframe")[0].contentDocument.documentElement.textContent.indexOf('\u4E2D'), 77, "Child doc should be HZ-GB-2312 initially");
    21   BrowserSetForcedCharacterSet("windows-1251");
    22 }
    24 function afterChangeCharset(event) {
    25   if (event.target != gBrowser.contentDocument) {
    26     return;
    27   }
    29   gBrowser.selectedBrowser.removeEventListener("load", afterChangeCharset, true);
    31   is(gBrowser.contentDocument.documentElement.textContent.indexOf('\u0402'), 140, "Parent doc should decode as windows-1251 subsequently");
    32   is(gBrowser.contentDocument.getElementsByTagName("iframe")[0].contentDocument.documentElement.textContent.indexOf('\u4E2D'), 77, "Child doc should decode as HZ-GB-2312 subsequently");  
    34   is(gBrowser.contentDocument.characterSet, "windows-1251", "Parent doc should report windows-1251 subsequently");
    35   is(gBrowser.contentDocument.getElementsByTagName("iframe")[0].contentDocument.characterSet, "HZ-GB-2312", "Child doc should report HZ-GB-2312 subsequently");
    37   gBrowser.removeCurrentTab();
    38   finish();
    39 }

mercurial