Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5084)

Unified Diff: chrome/test/data/extensions/api_test/bindings/function_interceptions.html

Issue 1748943002: [Extensions] Harden against bindings interception (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/extensions/extension_bindings_apitest.cc ('k') | extensions/renderer/module_system.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>
« no previous file with comments | « chrome/browser/extensions/extension_bindings_apitest.cc ('k') | extensions/renderer/module_system.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698