Repository: sinonjs/lolex (js)

Issue:
Cannot set property 'hrtime' of undefined
Hello,

After migrating from lolex 1.4.0 to 1.5.0, my tests fails with this exception:
```javascript
     TypeError: Cannot set property 'hrtime' of undefined
      at uninstall (node_modules/lolex/src/lolex-src.js:360:39)
      at Object.clock.uninstall (node_modules/lolex/src/lolex-src.js:629:13)
      at bus.close.then.then (test/scheduling/testScheduler.js:64:57)
```

I'm using nodejs 6.2.0.

My tests use lolex this way:

Setup:
```javascript
clock = lolex.install(context)
```

Tear down:
```javascript
clock.uninstall()
```

[lolex-src.js 1.5.0](https://github.com/sinonjs/lolex/blob/v1.5.0/src/lolex-src.js#L360) seems to assume that the context object has a key named `process`.

Any idea regarding this ? Does this mean that compatibility was broken somehow ?

Pull request description:
PR #62 repacked (fixes #59)
This is just @rogierschouten's work rebased (and squashed the two first commits into one). Look into #62 and #59 for details - nothing new.

Patch:
diff --git a/src/lolex-src.js b/src/lolex-src.js
index c1a5196..b19de4c 100644
--- a/src/lolex-src.js
+++ b/src/lolex-src.js
@@ -356,10 +356,10 @@
 
         for (i = 0, l = clock.methods.length; i < l; i++) {
             method = clock.methods[i];
-            if (method === "hrtime") {
+            if (method === "hrtime" && target.process) {
                 target.process.hrtime = clock[installedHrTime];
             } else {
-                if (target[method].hadOwnProperty) {
+                if (target[method] && target[method].hadOwnProperty) {
                     target[method] = clock["_" + method];
                 } else {
                     try {


Test patch:
diff --git a/test/lolex-test.js b/test/lolex-test.js
index 3fda1d7..e773bb3 100644
--- a/test/lolex-test.js
+++ b/test/lolex-test.js
@@ -29,6 +29,21 @@ var GlobalDate = Date;
 var NOOP = function NOOP() { return undefined; };
 var hrtimePresent = (global.process && typeof global.process.hrtime === "function");
 
+describe("issue #59", function () {
+    var context = {
+        Date: Date,
+        setTimeout: setTimeout,
+        clearTimeout: clearTimeout
+    };
+    var clock;
+
+    it("should install and uninstall the clock on a custom target", function () {
+        clock = lolex.install(context);
+        // this would throw an error before issue #59 was fixed
+        clock.uninstall();
+    });
+});
+
 describe("lolex", function () {
 
     describe("setTimeout", function () {