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

Side by Side Diff: chrome/test/data/extensions/api_test/messaging/connect/page.js

Issue 2387002: Prevent extensions from clobbering JSON implementation that extension calls use (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: arv cr changes Created 10 years, 6 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
1 JSON.parse = function() {
2 return "JSON.parse clobbered by content script.";
3 }
4
5 JSON.stringify = function() {
6 return "JSON.stringify clobbered by content script.";
7 }
8
9 Array.prototype.toJSON = function() {
10 return "Array.prototype.toJSON clobbered by content script.";
11 }
12
13 Object.prototype.toJSON = function() {
14 return "Object.prototype.toJSON clobbered by content script.";
15 }
16
1 // For complex connect tests. 17 // For complex connect tests.
2 chrome.extension.onConnect.addListener(function(port) { 18 chrome.extension.onConnect.addListener(function(port) {
3 console.log('connected'); 19 console.log('connected');
4 port.onMessage.addListener(function(msg) { 20 port.onMessage.addListener(function(msg) {
5 console.log('got ' + msg); 21 console.log('got ' + msg);
6 if (msg.testPostMessage) { 22 if (msg.testPostMessage) {
7 port.postMessage({success: true}); 23 port.postMessage({success: true});
8 } else if (msg.testPostMessageFromTab) { 24 } else if (msg.testPostMessageFromTab) {
9 testPostMessageFromTab(port); 25 testPostMessageFromTab(port);
10 } else if (msg.testSendRequestFromTab) { 26 } else if (msg.testSendRequestFromTab) {
(...skipping 27 matching lines...) Expand all
38 console.log('testSendRequestFromTab sent'); 54 console.log('testSendRequestFromTab sent');
39 chrome.extension.sendRequest({step: 2}); 55 chrome.extension.sendRequest({step: 2});
40 } 56 }
41 }); 57 });
42 } 58 }
43 59
44 // For test sendRequest. 60 // For test sendRequest.
45 chrome.extension.onRequest.addListener(function(request, sender, sendResponse) { 61 chrome.extension.onRequest.addListener(function(request, sender, sendResponse) {
46 sendResponse({success: (request.step2 == 1)}); 62 sendResponse({success: (request.step2 == 1)});
47 }); 63 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698