summaryrefslogtreecommitdiffstats
path: root/chrome/test
diff options
context:
space:
mode:
authorrafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-01 22:33:23 +0000
committerrafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-01 22:33:23 +0000
commit200dcd387d6902556e41e9439ce64f7f219f5809 (patch)
tree4389542472391337f43240c963ff282f696e8676 /chrome/test
parentbc2ff51999fe9ef5c041f2df2ffbbdb4c30baec9 (diff)
downloadchromium_src-200dcd387d6902556e41e9439ce64f7f219f5809.zip
chromium_src-200dcd387d6902556e41e9439ce64f7f219f5809.tar.gz
chromium_src-200dcd387d6902556e41e9439ce64f7f219f5809.tar.bz2
Prevent extensions from clobbering JSON implementation that extension calls use
BUG=38857 TEST=none Review URL: http://codereview.chromium.org/2387002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@48667 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r--chrome/test/data/extensions/api_test/messaging/connect/page.js16
-rw-r--r--chrome/test/data/extensions/api_test/messaging/connect/test.html16
2 files changed, 32 insertions, 0 deletions
diff --git a/chrome/test/data/extensions/api_test/messaging/connect/page.js b/chrome/test/data/extensions/api_test/messaging/connect/page.js
index b876f7e..9d45f64 100644
--- a/chrome/test/data/extensions/api_test/messaging/connect/page.js
+++ b/chrome/test/data/extensions/api_test/messaging/connect/page.js
@@ -1,3 +1,19 @@
+JSON.parse = function() {
+ return "JSON.parse clobbered by content script.";
+}
+
+JSON.stringify = function() {
+ return "JSON.stringify clobbered by content script.";
+}
+
+Array.prototype.toJSON = function() {
+ return "Array.prototype.toJSON clobbered by content script.";
+}
+
+Object.prototype.toJSON = function() {
+ return "Object.prototype.toJSON clobbered by content script.";
+}
+
// For complex connect tests.
chrome.extension.onConnect.addListener(function(port) {
console.log('connected');
diff --git a/chrome/test/data/extensions/api_test/messaging/connect/test.html b/chrome/test/data/extensions/api_test/messaging/connect/test.html
index 3e24916..4983a75 100644
--- a/chrome/test/data/extensions/api_test/messaging/connect/test.html
+++ b/chrome/test/data/extensions/api_test/messaging/connect/test.html
@@ -1,4 +1,20 @@
<script>
+JSON.parse = function() {
+ return "JSON.parse clobbered by extension.";
+}
+
+JSON.stringify = function() {
+ return "JSON.stringify clobbered by extension.";
+}
+
+Array.prototype.toJSON = function() {
+ return "Array.prototype.toJSON clobbered by extension.";
+}
+
+Object.prototype.toJSON = function() {
+ return "Object.prototype.toJSON clobbered by extension.";
+}
+
// Keep track of the tab that we're running tests in, for simplicity.
var testTab = null;