Index: chrome/test/data/extensions/api_test/bindings/function_interceptions.html |
diff --git a/chrome/test/data/extensions/api_test/bindings/function_interceptions.html b/chrome/test/data/extensions/api_test/bindings/function_interceptions.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..07342ca5180c027f9527179fd8a407e1dabe5697 |
--- /dev/null |
+++ b/chrome/test/data/extensions/api_test/bindings/function_interceptions.html |
@@ -0,0 +1,56 @@ |
+<body> |
+<script> |
+ |
+window.testStatus = ''; |
+var objects = ['runtime', 'require', 'test', 'binding']; |
+var leaked = []; |
+ |
+function intercept(objectKey) { |
+ Object.defineProperty(Object.prototype, objectKey, { |
+ get: function () { |
+ leaked.push({name: objectKey, obj: this}); |
+ }, |
+ set: function (v) { |
+ Object.defineProperty(this, objectKey, { |
+ value: v, |
+ configurable: true, |
+ enumerable: true, |
+ writable: true |
+ }); |
+ }, |
+ configurable: true, |
+ }); |
+} |
+ |
+// Set up interceptors. |
+for (let objectKey of objects) |
+ intercept(objectKey); |
+ |
+// Poke chrome.runtime and chrome.app. |
+try { |
+ chrome.runtime; |
+} catch (e) {} |
+try { |
+ chrome.app; |
+} catch (e) {} |
+ |
+// Cleanup - we don't want to be triggering our own interceptors. |
+for (let objKey of objects) |
+ delete Object.prototype[objKey]; |
+ |
+// Check what we intercepted. |
+var keysToCheck = ['utils', 'binding']; |
+for (let nameAndObj of leaked) { |
+ for (let key of keysToCheck) { |
+ if (!!nameAndObj.obj[key]) { |
+ window.testStatus += |
+ 'Failed: Found ' + key + ' on ' + nameAndObj.name + '\n'; |
+ } |
+ } |
+} |
+ |
+if (window.testStatus === '') |
+ window.testStatus = 'success'; |
+ |
+</script> |
+</body> |