(browser, options)
| 31 | let testServerURL; |
| 32 | |
| 33 | function runTest(browser, options) { |
| 34 | options = options || {}; |
| 35 | |
| 36 | if (process.env.CI) { |
| 37 | return Promise.resolve(); |
| 38 | } |
| 39 | |
| 40 | return createServer(options, webPush) |
| 41 | .then(function(server) { |
| 42 | globalServer = server; |
| 43 | testServerURL = 'http://127.0.0.1:' + server.port; |
| 44 | |
| 45 | if (browser.getId() === 'firefox') { |
| 46 | // This is based off of: https://bugzilla.mozilla.org/show_bug.cgi?id=1275521 |
| 47 | // Unfortunately it doesn't seem to work :( |
| 48 | const ffProfile = new seleniumFirefox.Profile(); |
| 49 | ffProfile.setPreference('dom.push.testing.ignorePermission', true); |
| 50 | ffProfile.setPreference('notification.prompt.testing', true); |
| 51 | ffProfile.setPreference('notification.prompt.testing.allow', true); |
| 52 | browser.getSeleniumOptions().setProfile(ffProfile); |
| 53 | } else if (browser.getId() === 'chrome') { |
| 54 | const chromeOperaPreferences = { |
| 55 | profile: { |
| 56 | content_settings: { |
| 57 | exceptions: { |
| 58 | notifications: {} |
| 59 | } |
| 60 | } |
| 61 | } |
| 62 | }; |
| 63 | chromeOperaPreferences.profile.content_settings.exceptions.notifications[testServerURL + ',*'] = { |
| 64 | setting: 1 |
| 65 | }; |
| 66 | /* eslint-enable camelcase */ |
| 67 | |
| 68 | // Write to a file |
| 69 | const tempPreferenceDir = './test/output/temp/chromeOperaPreferences'; |
| 70 | mkdirp.sync(tempPreferenceDir + '/Default'); |
| 71 | |
| 72 | // NOTE: The Default part of this path might be Chrome specific. |
| 73 | fs.writeFileSync(tempPreferenceDir + '/Default/Preferences', JSON.stringify(chromeOperaPreferences)); |
| 74 | |
| 75 | const seleniumOptions = browser.getSeleniumOptions(); |
| 76 | seleniumOptions.addArguments('user-data-dir=' + tempPreferenceDir + '/'); |
| 77 | } |
| 78 | |
| 79 | return browser.getSeleniumDriver(); |
| 80 | }) |
| 81 | .then(function(driver) { |
| 82 | globalDriver = driver; |
| 83 | |
| 84 | if (options.vapid) { |
| 85 | testServerURL += '?vapid=' + options.vapid.publicKey; |
| 86 | } |
| 87 | |
| 88 | return globalDriver.get(testServerURL) |
| 89 | .then(function() { |
| 90 | return globalDriver.executeScript(function() { |
no test coverage detected