Bug 1263878 - Randomize presentation session ID in test. r=schien, a=test-only
authorJunior Hsu <juhsu@mozilla.com>
Sun, 24 Apr 2016 23:21:00 -0400
changeset 378927 0b564c3446576a9a43531817d9d41cb35d20c424
parent 378926 7d547d913a2ee435ff7bc90c804a6012092c428d
child 378928 f32bd5cf50d3f09effa4eb2567d53292a57f7ecb
push id21011
push usermak77@bonardo.net
push dateThu, 16 Jun 2016 13:40:45 +0000
reviewersschien, test-only
bugs1263878
milestone47.0
Bug 1263878 - Randomize presentation session ID in test. r=schien, a=test-only
dom/presentation/tests/mochitest/PresentationSessionChromeScript.js
--- a/dom/presentation/tests/mochitest/PresentationSessionChromeScript.js
+++ b/dom/presentation/tests/mochitest/PresentationSessionChromeScript.js
@@ -2,16 +2,19 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 'use strict';
 
 const { classes: Cc, interfaces: Ci, manager: Cm, utils: Cu, results: Cr } = Components;
 
 Cu.import('resource://gre/modules/XPCOMUtils.jsm');
 
+const uuidGenerator = Cc["@mozilla.org/uuid-generator;1"]
+                      .getService(Ci.nsIUUIDGenerator);
+
 function registerMockedFactory(contractId, mockedClassId, mockedFactory) {
   var originalClassId, originalFactory;
 
   var registrar = Cm.QueryInterface(Ci.nsIComponentRegistrar);
   if (!registrar.isCIDRegistered(mockedClassId)) {
     try {
       originalClassId = registrar.contractIDToCID(contractId);
       originalFactory = Cm.getClassObject(Cc[contractId], Ci.nsIFactory);
@@ -34,17 +37,17 @@ function registerMockedFactory(contractI
 
 function registerOriginalFactory(contractId, mockedClassId, mockedFactory, originalClassId, originalFactory) {
   if (originalFactory) {
     registrar.unregisterFactory(mockedClassId, mockedFactory);
     registrar.registerFactory(originalClassId, "", contractId, originalFactory);
   }
 }
 
-const sessionId = 'test-session-id';
+const sessionId = 'test-session-id-' + uuidGenerator.generateUUID().toString();
 
 const address = Cc["@mozilla.org/supports-cstring;1"]
                   .createInstance(Ci.nsISupportsCString);
 address.data = "127.0.0.1";
 const addresses = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
 addresses.appendElement(address, false);
 
 const mockedChannelDescription = {
@@ -288,18 +291,16 @@ const mockedRequestUIGlue = {
   },
   sendRequest: function(aUrl, aSessionId) {
     sendAsyncMessage('receiver-launching', aSessionId);
     return requestPromise;
   },
 };
 
 // Register mocked factories.
-const uuidGenerator = Cc["@mozilla.org/uuid-generator;1"]
-                      .getService(Ci.nsIUUIDGenerator);
 const originalFactoryData = [];
 originalFactoryData.push(registerMockedFactory("@mozilla.org/presentation-device/prompt;1",
                                                uuidGenerator.generateUUID(),
                                                mockedDevicePrompt));
 originalFactoryData.push(registerMockedFactory("@mozilla.org/network/server-socket;1",
                                                uuidGenerator.generateUUID(),
                                                mockedServerSocket));
 originalFactoryData.push(registerMockedFactory("@mozilla.org/presentation/presentationsessiontransport;1",