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

Side by Side 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, 9 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 unified diff | Download patch
OLDNEW
(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>
OLDNEW
« 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