This source file includes following definitions.
- TEST_F
- TEST_F
- TEST_F
- TEST_F
#include "chrome/test/base/module_system_test.h"
#include "grit/renderer_resources.h"
namespace extensions {
namespace {
class SafeBuiltinsUnittest : public ModuleSystemTest {
};
TEST_F(SafeBuiltinsUnittest, TestNotOriginalObject) {
ModuleSystem::NativesEnabledScope natives_enabled_scope(
context_->module_system());
RegisterModule("test",
"var assert = requireNative('assert');\n"
"Array.foo = 10;\n"
"assert.AssertTrue(!$Array.hasOwnProperty('foo'));\n"
);
context_->module_system()->Require("test");
}
TEST_F(SafeBuiltinsUnittest, TestSelf) {
ModuleSystem::NativesEnabledScope natives_enabled_scope(
context_->module_system());
RegisterModule("test",
"var assert = requireNative('assert');\n"
"Array.foo = 10;\n"
"assert.AssertTrue($Array.self.foo == 10);\n"
"var arr = $Array.self(1);\n"
"assert.AssertTrue(arr.length == 1);\n"
"assert.AssertTrue(arr[0] === undefined);\n"
);
context_->module_system()->Require("test");
}
TEST_F(SafeBuiltinsUnittest, TestStaticFunction) {
ModuleSystem::NativesEnabledScope natives_enabled_scope(
context_->module_system());
RegisterModule("test",
"var assert = requireNative('assert');\n"
"Object.keys = function() {throw new Error()};\n"
"var obj = {a: 10};\n"
"var keys = $Object.keys(obj);\n"
"assert.AssertTrue(keys.length == 1);\n"
"assert.AssertTrue(keys[0] == 'a');\n"
);
context_->module_system()->Require("test");
}
TEST_F(SafeBuiltinsUnittest, TestInstanceMethod) {
ModuleSystem::NativesEnabledScope natives_enabled_scope(
context_->module_system());
RegisterModule("test",
"var assert = requireNative('assert');\n"
"Array.prototype.push = function() {throw new Error();}\n"
"var arr = []\n"
"$Array.push(arr, 1);\n"
"assert.AssertTrue(arr.length == 1);\n"
"assert.AssertTrue(arr[0] == 1);\n"
);
context_->module_system()->Require("test");
}
}
}