mirror of
https://github.com/atom/atom.git
synced 2026-01-24 14:28:14 -05:00
RootView serialize absorbs exceptions when serializing extensions
This commit is contained in:
@@ -111,6 +111,27 @@ describe "RootView", ->
|
||||
expect(rootView.editors().length).toBe 0
|
||||
expect(document.title).toBe 'untitled'
|
||||
|
||||
describe ".serialize()", ->
|
||||
it "absorbs exceptions that are thrown by extension serialize methods", ->
|
||||
spyOn(console, 'error')
|
||||
|
||||
rootView.activateExtension(
|
||||
name: "bad-egg"
|
||||
activate: ->
|
||||
serialize: -> throw new Error("I'm broken")
|
||||
)
|
||||
|
||||
rootView.activateExtension(
|
||||
name: "good-egg"
|
||||
activate: ->
|
||||
serialize: -> "I still get called"
|
||||
)
|
||||
|
||||
data = rootView.serialize()
|
||||
expect(data.extensionStates['good-egg']).toBe "I still get called"
|
||||
expect(data.extensionStates['bad-egg']).toBeUndefined()
|
||||
expect(console.error).toHaveBeenCalled()
|
||||
|
||||
describe "focus", ->
|
||||
it "can receive focus if there is no active editor, but otherwise hands off focus to the active editor", ->
|
||||
rootView = new RootView(require.resolve 'fixtures')
|
||||
|
||||
@@ -66,8 +66,10 @@ class RootView extends View
|
||||
serializeExtensions: ->
|
||||
extensionStates = {}
|
||||
for name, extension of @extensions
|
||||
extensionStates[name] = extension.serialize?()
|
||||
|
||||
try
|
||||
extensionStates[name] = extension.serialize?()
|
||||
catch e
|
||||
console?.error("Exception serializing '#{name}' extension", e)
|
||||
extensionStates
|
||||
|
||||
deserializeView: (viewState) ->
|
||||
|
||||
Reference in New Issue
Block a user