Fix the atom:// URL handler for real (with tests this time)

This commit is contained in:
hansonw
2017-05-16 11:37:53 -07:00
parent 9a42f82895
commit e8cd4bf431
4 changed files with 31 additions and 1 deletions

View File

@@ -0,0 +1,4 @@
module.exports = function initialize() {
global.reachedUrlMain = true;
return Promise.resolve();
};

View File

@@ -0,0 +1,5 @@
{
"name": "package-with-url-main",
"version": "1.0.0",
"urlMain": "./index.js"
}

View File

@@ -437,6 +437,27 @@ describe('AtomApplication', function () {
assert.deepEqual(await getTreeViewRootDirectories(window2), [dirB])
})
})
describe('when opening atom:// URLs', function () {
it('loads the urlMain file in a new window', async function () {
const packagePath = path.join(__dirname, '..', 'fixtures', 'packages', 'package-with-url-main')
const packagesDirPath = path.join(process.env.ATOM_HOME, 'packages')
fs.mkdirSync(packagesDirPath)
fs.symlinkSync(packagePath, path.join(packagesDirPath, 'package-with-url-main'), 'junction')
const atomApplication = buildAtomApplication()
const launchOptions = parseCommandLine([])
launchOptions.urlsToOpen = ['atom://package-with-url-main/test']
let windows = atomApplication.launch(launchOptions)
await windows[0].loadedPromise
let reached = await evalInWebContents(windows[0].browserWindow.webContents, function (sendBackToMainProcess) {
sendBackToMainProcess(global.reachedUrlMain)
})
assert.equal(reached, true);
windows[0].close();
})
})
})
describe('before quitting', function () {

View File

@@ -644,7 +644,7 @@ class AtomApplication
openUrl: ({urlToOpen, devMode, safeMode, env}) ->
unless @packages?
PackageManager = require '../package-manager'
@packages = new PackageManager()
@packages = new PackageManager({})
@packages.initialize
configDirPath: process.env.ATOM_HOME
devMode: devMode