dom/tests/mochitest/webapps/file_bug_779982.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/tests/mochitest/webapps/file_bug_779982.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,89 @@
     1.4 +SimpleTest.waitForExplicitFinish();
     1.5 +SpecialPowers.setAllAppsLaunchable(true);
     1.6 +
     1.7 +var fileTestOnCurrentOrigin = 'http://example.org/tests/dom/tests/mochitest/webapps/file_bug_779982.html';
     1.8 +
     1.9 +var gData = [
    1.10 +  // APP 1
    1.11 +  {
    1.12 +    app: 'http://example.org/manifest.webapp',
    1.13 +    action: 'getSelf',
    1.14 +    isnull: false,
    1.15 +    src: fileTestOnCurrentOrigin,
    1.16 +    message: 'getSelf() for app should return something'
    1.17 +  },
    1.18 +  {
    1.19 +    app: 'http://example.org/manifest.webapp',
    1.20 +    action: 'checkInstalled',
    1.21 +    isnull: false,
    1.22 +    src: fileTestOnCurrentOrigin,
    1.23 +    message: 'checkInstalled() for app should return true'
    1.24 +  },
    1.25 +  {
    1.26 +    app: 'http://example.org/manifest.webapp',
    1.27 +    action: 'checkInstalledWrong',
    1.28 +    isnull: true,
    1.29 +    src: fileTestOnCurrentOrigin,
    1.30 +    message: 'checkInstalled() for browser should return true'
    1.31 +  },
    1.32 +  // Browser
    1.33 +  {
    1.34 +    browser: true,
    1.35 +    action: 'getSelf',
    1.36 +    isnull: true,
    1.37 +    src: fileTestOnCurrentOrigin,
    1.38 +    message: 'getSelf() for browser should return null'
    1.39 +  },
    1.40 +  {
    1.41 +    browser: true,
    1.42 +    action: 'checkInstalled',
    1.43 +    isnull: false,
    1.44 +    src: fileTestOnCurrentOrigin,
    1.45 +    message: 'checkInstalled() for browser should return true'
    1.46 +  },
    1.47 +  {
    1.48 +    browser: true,
    1.49 +    action: 'checkInstalledWrong',
    1.50 +    isnull: true,
    1.51 +    src: fileTestOnCurrentOrigin,
    1.52 +    message: 'checkInstalled() for browser should return true'
    1.53 +  },
    1.54 +];
    1.55 +
    1.56 +function runTest() {
    1.57 +  for (var i in gData) {
    1.58 +    var iframe = document.createElement('iframe');
    1.59 +    var data = gData[i];
    1.60 +
    1.61 +    if (data.app) {
    1.62 +      iframe.setAttribute('mozbrowser', '');
    1.63 +      iframe.setAttribute('mozapp', data.app);
    1.64 +    } else if (data.browser) {
    1.65 +      iframe.setAttribute('mozbrowser', '');
    1.66 +    }
    1.67 +
    1.68 +    if (data.app || data.browser) {
    1.69 +      iframe.addEventListener('mozbrowsershowmodalprompt', function(e) {
    1.70 +        is(e.detail.message, 'success', data.message);
    1.71 +
    1.72 +        i++;
    1.73 +        if (i >= gData.length) {
    1.74 +          SimpleTest.finish();
    1.75 +        } else {
    1.76 +          gTestRunner.next();
    1.77 +        }
    1.78 +      });
    1.79 +    }
    1.80 +
    1.81 +    iframe.src = data.src + '?' + data.action + '&' + data.isnull;
    1.82 +    document.getElementById('content').appendChild(iframe);
    1.83 +
    1.84 +    yield undefined;
    1.85 +  }
    1.86 +}
    1.87 +
    1.88 +var gTestRunner = runTest();
    1.89 +
    1.90 +SpecialPowers.pushPrefEnv({"set": [["dom.mozBrowserFramesEnabled", true]]}, function() {
    1.91 +  SpecialPowers.pushPermissions([{'type': 'browser', 'allow': true, 'context': document}, {'type': 'embed-apps', 'allow': true, 'context': document}], function() {gTestRunner.next() });
    1.92 +});

mercurial