dom/tests/mochitest/webapps/file_bug_779982.js

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 SimpleTest.waitForExplicitFinish();
     2 SpecialPowers.setAllAppsLaunchable(true);
     4 var fileTestOnCurrentOrigin = 'http://example.org/tests/dom/tests/mochitest/webapps/file_bug_779982.html';
     6 var gData = [
     7   // APP 1
     8   {
     9     app: 'http://example.org/manifest.webapp',
    10     action: 'getSelf',
    11     isnull: false,
    12     src: fileTestOnCurrentOrigin,
    13     message: 'getSelf() for app should return something'
    14   },
    15   {
    16     app: 'http://example.org/manifest.webapp',
    17     action: 'checkInstalled',
    18     isnull: false,
    19     src: fileTestOnCurrentOrigin,
    20     message: 'checkInstalled() for app should return true'
    21   },
    22   {
    23     app: 'http://example.org/manifest.webapp',
    24     action: 'checkInstalledWrong',
    25     isnull: true,
    26     src: fileTestOnCurrentOrigin,
    27     message: 'checkInstalled() for browser should return true'
    28   },
    29   // Browser
    30   {
    31     browser: true,
    32     action: 'getSelf',
    33     isnull: true,
    34     src: fileTestOnCurrentOrigin,
    35     message: 'getSelf() for browser should return null'
    36   },
    37   {
    38     browser: true,
    39     action: 'checkInstalled',
    40     isnull: false,
    41     src: fileTestOnCurrentOrigin,
    42     message: 'checkInstalled() for browser should return true'
    43   },
    44   {
    45     browser: true,
    46     action: 'checkInstalledWrong',
    47     isnull: true,
    48     src: fileTestOnCurrentOrigin,
    49     message: 'checkInstalled() for browser should return true'
    50   },
    51 ];
    53 function runTest() {
    54   for (var i in gData) {
    55     var iframe = document.createElement('iframe');
    56     var data = gData[i];
    58     if (data.app) {
    59       iframe.setAttribute('mozbrowser', '');
    60       iframe.setAttribute('mozapp', data.app);
    61     } else if (data.browser) {
    62       iframe.setAttribute('mozbrowser', '');
    63     }
    65     if (data.app || data.browser) {
    66       iframe.addEventListener('mozbrowsershowmodalprompt', function(e) {
    67         is(e.detail.message, 'success', data.message);
    69         i++;
    70         if (i >= gData.length) {
    71           SimpleTest.finish();
    72         } else {
    73           gTestRunner.next();
    74         }
    75       });
    76     }
    78     iframe.src = data.src + '?' + data.action + '&' + data.isnull;
    79     document.getElementById('content').appendChild(iframe);
    81     yield undefined;
    82   }
    83 }
    85 var gTestRunner = runTest();
    87 SpecialPowers.pushPrefEnv({"set": [["dom.mozBrowserFramesEnabled", true]]}, function() {
    88   SpecialPowers.pushPermissions([{'type': 'browser', 'allow': true, 'context': document}, {'type': 'embed-apps', 'allow': true, 'context': document}], function() {gTestRunner.next() });
    89 });

mercurial