OLD | NEW |
(Empty) | |
| 1 <body> |
| 2 <script> |
| 3 |
| 4 window.testStatus = ''; |
| 5 var objects = ['runtime', 'require', 'test', 'binding']; |
| 6 var leaked = []; |
| 7 |
| 8 function intercept(objectKey) { |
| 9 Object.defineProperty(Object.prototype, objectKey, { |
| 10 get: function () { |
| 11 leaked.push({name: objectKey, obj: this}); |
| 12 }, |
| 13 set: function (v) { |
| 14 Object.defineProperty(this, objectKey, { |
| 15 value: v, |
| 16 configurable: true, |
| 17 enumerable: true, |
| 18 writable: true |
| 19 }); |
| 20 }, |
| 21 configurable: true, |
| 22 }); |
| 23 } |
| 24 |
| 25 // Set up interceptors. |
| 26 for (let objectKey of objects) |
| 27 intercept(objectKey); |
| 28 |
| 29 // Poke chrome.runtime and chrome.app. |
| 30 try { |
| 31 chrome.runtime; |
| 32 } catch (e) {} |
| 33 try { |
| 34 chrome.app; |
| 35 } catch (e) {} |
| 36 |
| 37 // Cleanup - we don't want to be triggering our own interceptors. |
| 38 for (let objKey of objects) |
| 39 delete Object.prototype[objKey]; |
| 40 |
| 41 // Check what we intercepted. |
| 42 var keysToCheck = ['utils', 'binding']; |
| 43 for (let nameAndObj of leaked) { |
| 44 for (let key of keysToCheck) { |
| 45 if (!!nameAndObj.obj[key]) { |
| 46 window.testStatus += |
| 47 'Failed: Found ' + key + ' on ' + nameAndObj.name + '\n'; |
| 48 } |
| 49 } |
| 50 } |
| 51 |
| 52 if (window.testStatus === '') |
| 53 window.testStatus = 'success'; |
| 54 |
| 55 </script> |
| 56 </body> |
OLD | NEW |