services/wspr: Intentionally panic from within a goroutine.

This is used in the js test-nacl-plugin-crash test.

For some reason directly calling "panic" sometimes blocks and never
causes the "crash" event to be emitted.  Calling "panic" from within a
goroutine causes a "full" panic, making the js test much more reliable.

MultiPart: 2/2

Change-Id: I27b69af44049657e8f23a086d20ea1f6c0b776c3
diff --git a/services/wspr/browsprd/main_nacl.go b/services/wspr/browsprd/main_nacl.go
index 98758bc..5b9db6b 100644
--- a/services/wspr/browsprd/main_nacl.go
+++ b/services/wspr/browsprd/main_nacl.go
@@ -311,10 +311,18 @@
 	return nil
 }
 
-// HandleIntentionalPanic intentionally triggers a panic. This is used in tests of the extension's crash handling behavior.
-// TODO(bprosnitz) We probably should conditionally compile this in via build tags so we don't hit it in production code.
+// HandleIntentionalPanic intentionally triggers a panic. This is used in tests
+// of the extension's crash handling behavior.
+// TODO(bprosnitz) We probably should conditionally compile this in via build
+// tags so we don't hit it in production code.
 func (inst *browsprInstance) HandleIntentionalPanic(instanceId int32, origin string, message ppapi.Var) error {
-	panic("Crashing intentionally")
+	// NOTE(nlacasse): Calling panic directly (not inside a goroutine)
+	// sometimes blocks during the panic, causing the plugin to not emit a
+	// "crash" event. I'm not sure why this happens, but it breaks the
+	// test-nacl-plugin-crash test. Calling panic from within a goroutine seems
+	// to reliably panic "all the way" and emit a "crash" event.
+	go panic("Crashing intentionally")
+	return nil
 }
 
 // HandleBrowsprRpc handles two-way rpc messages of the type "browsprRpc"