mirror of
https://github.com/atom/atom.git
synced 2026-01-23 05:48:10 -05:00
Use "shell.openExternal(url)" to open links in external browsers.
This commit is contained in:
@@ -232,22 +232,22 @@ describe "Window", ->
|
||||
|
||||
describe "when a link is clicked", ->
|
||||
it "opens the http/https links in an external application", ->
|
||||
ChildProcess = require 'child_process'
|
||||
spyOn(ChildProcess, 'spawn')
|
||||
shell = require 'shell'
|
||||
spyOn(shell, 'openExternal')
|
||||
|
||||
$("<a href='http://github.com'>the website</a>").appendTo(document.body).click().remove()
|
||||
expect(ChildProcess.spawn).toHaveBeenCalled()
|
||||
expect(ChildProcess.spawn.argsForCall[0][1][0]).toBe "http://github.com"
|
||||
expect(shell.openExternal).toHaveBeenCalled()
|
||||
expect(shell.openExternal.argsForCall[0]).toBe "http://github.com"
|
||||
|
||||
ChildProcess.spawn.reset()
|
||||
shell.openExternal.reset()
|
||||
$("<a href='https://github.com'>the website</a>").appendTo(document.body).click().remove()
|
||||
expect(ChildProcess.spawn).toHaveBeenCalled()
|
||||
expect(ChildProcess.spawn.argsForCall[0][1][0]).toBe "https://github.com"
|
||||
expect(shell.openExternal).toHaveBeenCalled()
|
||||
expect(shell.openExternal.argsForCall[0]).toBe "https://github.com"
|
||||
|
||||
ChildProcess.spawn.reset()
|
||||
shell.openExternal.reset()
|
||||
$("<a href=''>the website</a>").appendTo(document.body).click().remove()
|
||||
expect(ChildProcess.spawn).not.toHaveBeenCalled()
|
||||
expect(shell.openExternal).not.toHaveBeenCalled()
|
||||
|
||||
ChildProcess.spawn.reset()
|
||||
shell.openExternal.reset()
|
||||
$("<a href='#scroll-me'>link</a>").appendTo(document.body).click().remove()
|
||||
expect(ChildProcess.spawn).not.toHaveBeenCalled()
|
||||
expect(shell.openExternal).not.toHaveBeenCalled()
|
||||
|
||||
@@ -125,7 +125,7 @@ window.handleEvents = ->
|
||||
return if location[0] is '#'
|
||||
|
||||
if location.indexOf('https://') is 0 or location.indexOf('http://') is 0
|
||||
require('child_process').spawn('open', [location])
|
||||
require('shell').openExternal(location)
|
||||
false
|
||||
|
||||
window.handleDragDrop = ->
|
||||
|
||||
@@ -12,5 +12,4 @@ module.exports =
|
||||
@selector = new TextMateScopeSelector('markup.underline.link')
|
||||
|
||||
if @selector.matches(token.scopes)
|
||||
ChildProcess = require 'child_process'
|
||||
ChildProcess.spawn 'open', [token.value]
|
||||
require('shell').openExternal token.value
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
RootView = require 'root-view'
|
||||
Editor = require 'editor'
|
||||
ChildProcess = require 'child_process'
|
||||
shell = require 'shell'
|
||||
|
||||
describe "link package", ->
|
||||
[editor] = []
|
||||
@@ -17,12 +17,12 @@ describe "link package", ->
|
||||
|
||||
describe "when the cursor is on a link", ->
|
||||
it "opens the link using the 'open' command", ->
|
||||
spyOn(ChildProcess, 'spawn')
|
||||
spyOn(shell, 'openExternal')
|
||||
editor.trigger('link:open')
|
||||
expect(ChildProcess.spawn).not.toHaveBeenCalled()
|
||||
expect(shell.openExternal).not.toHaveBeenCalled()
|
||||
|
||||
editor.setCursorBufferPosition([0,5])
|
||||
editor.trigger('link:open')
|
||||
|
||||
expect(ChildProcess.spawn).toHaveBeenCalled()
|
||||
expect(ChildProcess.spawn.argsForCall[0][1][0]).toBe "http://github.com"
|
||||
expect(shell.openExternal).toHaveBeenCalled()
|
||||
expect(shell.openExternal.argsForCall[0]).toBe "http://github.com"
|
||||
|
||||
Reference in New Issue
Block a user