summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryurys@google.com <yurys@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-08 13:44:35 +0000
committeryurys@google.com <yurys@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-08 13:44:35 +0000
commit2dd1eb91fa07a6ec9a708093525834d7eab5a95e (patch)
tree2ce04c6e94848ff8dc2ff1fad390e7d5f22c52f5
parent585592647a2f6b8d9cb3f8e034dcbc046d5c5f83 (diff)
downloadchromium_src-2dd1eb91fa07a6ec9a708093525834d7eab5a95e.zip
chromium_src-2dd1eb91fa07a6ec9a708093525834d7eab5a95e.tar.gz
chromium_src-2dd1eb91fa07a6ec9a708093525834d7eab5a95e.tar.bz2
DevTools: fix and reenable TestDebugIntrinsicProperties
Review URL: http://codereview.chromium.org/268015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28389 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/debugger/devtools_sanity_unittest.cc2
-rw-r--r--webkit/glue/devtools/js/tests.js75
2 files changed, 50 insertions, 27 deletions
diff --git a/chrome/browser/debugger/devtools_sanity_unittest.cc b/chrome/browser/debugger/devtools_sanity_unittest.cc
index 35c5587..3db7ac5 100644
--- a/chrome/browser/debugger/devtools_sanity_unittest.cc
+++ b/chrome/browser/debugger/devtools_sanity_unittest.cc
@@ -201,7 +201,7 @@ IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestExpandScope) {
// Tests that intrinsic properties(__proto__, prototype, constructor) are
// present.
-IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, DISABLED_TestDebugIntrinsicProperties) {
+IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestDebugIntrinsicProperties) {
RunTest("testDebugIntrinsicProperties", kDebuggerIntrinsicPropertiesPage);
}
diff --git a/webkit/glue/devtools/js/tests.js b/webkit/glue/devtools/js/tests.js
index 5cbc404..b547c77 100644
--- a/webkit/glue/devtools/js/tests.js
+++ b/webkit/glue/devtools/js/tests.js
@@ -1128,15 +1128,18 @@ TestSuite.prototype._expandScopeSections = function(filter, callback) {
if (!filter(sections, i)) {
continue;
}
- this.addSniffer(section, 'updateProperties', updateListener);
++toBeUpdatedCount;
var populated = section.populated;
- section.expand();
- if (populated) {
- // Make sure 'updateProperties' callback will be called at least once
- // after it was overridden.
- section.update();
- }
+
+ this._hookGetPropertiesCallback(updateListener,
+ function() {
+ section.expand();
+ if (populated) {
+ // Make sure 'updateProperties' callback will be called at least once
+ // after it was overridden.
+ section.update();
+ }
+ });
}
};
@@ -1234,6 +1237,31 @@ TestSuite.prototype._findChildProperty = function(parent, childName) {
/**
+ * Executes the 'code' with InjectedScriptAccess.getProperties overriden
+ * so that all callbacks passed to InjectedScriptAccess.getProperties are
+ * extended with the 'hook'.
+ * @param {Function} hook The hook function.
+ * @param {Function} code A code snippet to be executed.
+ */
+TestSuite.prototype._hookGetPropertiesCallback = function(hook, code) {
+ var orig = InjectedScriptAccess.getProperties;
+ InjectedScriptAccess.getProperties = function(objectProxy,
+ ignoreHasOwnProperty, callback) {
+ orig.call(InjectedScriptAccess, objectProxy, ignoreHasOwnProperty,
+ function() {
+ callback.apply(this, arguments);
+ hook();
+ });
+ };
+ try {
+ code();
+ } finally {
+ InjectedScriptAccess.getProperties = orig;
+ }
+};
+
+
+/**
* Tests that all elements in prototype chain of an object have expected
* intrinic proprties(__proto__, constructor, prototype).
*/
@@ -1272,9 +1300,12 @@ TestSuite.prototype.testDebugIntrinsicProperties = function() {
localScopeSection.propertiesTreeOutline, 'a');
test.assertTrue(!!aTreeElement, 'Not found');
- var orig = overrideGetProperties(checkA.bind(null, aTreeElement));
- aTreeElement.expand();
- InjectedScriptAccess.getProperties = orig;
+ test._hookGetPropertiesCallback(
+ checkA.bind(null, aTreeElement),
+ function () {
+ aTreeElement.expand();
+ });
+
}
function checkA(aTreeElement) {
@@ -1283,6 +1314,8 @@ TestSuite.prototype.testDebugIntrinsicProperties = function() {
'constructor', 'function Child()',
'__proto__', 'Object',
'prototype', 'undefined',
+ 'parentField', '10',
+ 'childField', '20',
]);
expandProto(aTreeElement, checkAProto);
}
@@ -1293,6 +1326,7 @@ TestSuite.prototype.testDebugIntrinsicProperties = function() {
'constructor', 'function Child()',
'__proto__', 'Object',
'prototype', 'undefined',
+ 'childProtoField', '21',
]);
expandProto(treeElement, checkAProtoProto);
}
@@ -1303,6 +1337,7 @@ TestSuite.prototype.testDebugIntrinsicProperties = function() {
'constructor', 'function Parent()',
'__proto__', 'Object',
'prototype', 'undefined',
+ 'parentProtoField', '11',
]);
expandProto(treeElement, checkAProtoProtoProto);
}
@@ -1317,26 +1352,14 @@ TestSuite.prototype.testDebugIntrinsicProperties = function() {
test.releaseControl();
}
- function overrideGetProperties(afterCallback) {
- var orig = InjectedScriptAccess.getProperties;
- InjectedScriptAccess.getProperties = function(objectProxy,
- ignoreHasOwnProperty, callback) {
- orig.call(InjectedScriptAccess, objectProxy, ignoreHasOwnProperty,
- function() {
- callback.apply(this, arguments);
- afterCallback();
- });
- };
- return orig;
- }
-
function expandProto(treeElement, callback) {
var proto = test._findChildProperty(treeElement, '__proto__');
test.assertTrue(proto, '__proro__ not found');
- var orig = overrideGetProperties(callback.bind(null, proto));
- proto.expand();
- InjectedScriptAccess.getProperties = orig;
+ test._hookGetPropertiesCallback(callback.bind(null, proto),
+ function() {
+ proto.expand();
+ });
}
function checkIntrinsicProperties(treeElement, expectations) {