]> khamidou — GitHub mirrors - electron.git/commitdiff
spec: Use random port when creating http server.
authorCheng Zhao <zcbenz@gmail.com>
Thu, 24 Apr 2014 07:42:37 +0000 (15:42 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Thu, 24 Apr 2014 07:42:37 +0000 (15:42 +0800)
spec/api-crash-reporter-spec.coffee
spec/fixtures/api/crash.html

index 3aad097239d0bcd06771be12754c73e874229b84..372ada3beeefaf59f79fe792b68cd88c819cb945 100644 (file)
@@ -1,6 +1,7 @@
 assert     = require 'assert'
 path       = require 'path'
 http       = require 'http'
+url        = require 'url'
 remote     = require 'remote'
 formidable = require 'formidable'
 
@@ -31,5 +32,10 @@ describe 'crash-reporter module', ->
         res.end()
         server.close()
         done()
-    server.listen 1127, '127.0.0.1', ->
-      w.loadUrl 'file://' + path.join(fixtures, 'api', 'crash.html')
+    port = Math.floor(Math.random() * 55535 + 10000)
+    server.listen port, '127.0.0.1', ->
+      url = url.format
+        protocol: 'file'
+        pathname: path.join fixtures, 'api', 'crash.html'
+        search: "?port=#{port}"
+      w.loadUrl url
index cb6c43586a32ceed1834cb03785311e89006e2c3..db1518b8c9eea595c5ddba989218e0ee8e00e79d 100644 (file)
@@ -1,11 +1,12 @@
 <html>
 <body>
 <script type="text/javascript" charset="utf-8">
+var port = require('url').parse(window.location.href, true).query.port;
 var crashReporter = require('crash-reporter');
 crashReporter.start({
   productName: 'Zombies',
   companyName: 'Umbrella Corporation',
-  submitUrl: 'http://127.0.0.1:1127',
+  submitUrl: 'http://127.0.0.1:' + port,
   autoSubmit: true,
   ignoreSystemCrashHandler: true,
   extra: {