mirror of
https://github.com/atom/atom.git
synced 2026-01-21 04:48:12 -05:00
Fix the atom:// URL handler for real (with tests this time)
This commit is contained in:
4
spec/fixtures/packages/package-with-url-main/index.js
vendored
Normal file
4
spec/fixtures/packages/package-with-url-main/index.js
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
module.exports = function initialize() {
|
||||
global.reachedUrlMain = true;
|
||||
return Promise.resolve();
|
||||
};
|
||||
5
spec/fixtures/packages/package-with-url-main/package.json
vendored
Normal file
5
spec/fixtures/packages/package-with-url-main/package.json
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"name": "package-with-url-main",
|
||||
"version": "1.0.0",
|
||||
"urlMain": "./index.js"
|
||||
}
|
||||
@@ -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 () {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user