Skip to content
This repository has been archived by the owner on Feb 26, 2022. It is now read-only.

Commit

Permalink
Merge pull request #650 from erikvold/808745
Browse files Browse the repository at this point in the history
fix bug 808745 removing FF9 related code for content-proxy r=@Gozala(cherry picked from commit d949768)
  • Loading branch information
erikvold authored and KWierso committed Nov 13, 2012
1 parent 560bfbd commit 53a51a0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 31 deletions.
23 changes: 4 additions & 19 deletions lib/sdk/content/content-proxy.js
Expand Up @@ -483,7 +483,7 @@ function isEventName(id) {
// Here is a list of functions that return a value when it detects a miss:
const NODES_INDEXED_BY_NAME = ["IMG", "FORM", "APPLET", "EMBED", "OBJECT"];
const xRayWrappersMissFixes = [

// Fix bug with XPCNativeWrapper on HTMLCollection
// We can only access array item once, then it's undefined :o
function (obj, name) {
Expand All @@ -494,7 +494,7 @@ const xRayWrappersMissFixes = [
}
return null;
},

// Trap access to document["form name"]
// that may refer to an existing form node
// http://mxr.mozilla.org/mozilla-central/source/dom/base/nsDOMClassInfo.cpp#9285
Expand All @@ -508,7 +508,7 @@ const xRayWrappersMissFixes = [
}
return null;
},

// Trap access to window["frame name"] and window.frames[i]
// that refer to an (i)frame internal window object
// http://mxr.mozilla.org/mozilla-central/source/dom/base/nsDOMClassInfo.cpp#6824
Expand Down Expand Up @@ -541,7 +541,7 @@ const xRayWrappersMissFixes = [
}
return null;
},

// Trap access to form["node name"]
// http://mxr.mozilla.org/mozilla-central/source/dom/base/nsDOMClassInfo.cpp#9477
function (obj, name) {
Expand All @@ -555,21 +555,6 @@ const xRayWrappersMissFixes = [
}
}
return null;
},

// Fix XPathResult's constants being undefined on XrayWrappers
// these constants are defined here:
// http://mxr.mozilla.org/mozilla-central/source/dom/interfaces/xpath/nsIDOMXPathResult.idl
// and are only numbers.
// The platform bug 665279 was fixed in Gecko 10.0a1.
// FIXME: remove this workaround once the SDK no longer supports Firefox 9.
function (obj, name) {
if (typeof obj == "object" && name in Ci.nsIDOMXPathResult) {
let value = Ci.nsIDOMXPathResult[name];
if (typeof value == "number" && value === obj.wrappedJSObject[name])
return value;
}
return null;
}

];
Expand Down
32 changes: 20 additions & 12 deletions test/test-content-proxy.js
Expand Up @@ -638,20 +638,29 @@ exports.testXMLHttpRequest = createProxyTest("", function (helper) {
});

exports.testXPathResult = createProxyTest("", function (helper, test) {

// Check XPathResult bug with constants being undefined on
// XPCNativeWrapper
let value = helper.rawWindow.XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE;
const XPathResultTypes = ["ANY_TYPE",
"NUMBER_TYPE", "STRING_TYPE", "BOOLEAN_TYPE",
"UNORDERED_NODE_ITERATOR_TYPE",
"ORDERED_NODE_ITERATOR_TYPE",
"UNORDERED_NODE_SNAPSHOT_TYPE",
"ORDERED_NODE_SNAPSHOT_TYPE",
"ANY_UNORDERED_NODE_TYPE",
"FIRST_ORDERED_NODE_TYPE"];

// Check XPathResult bug with constants being undefined on XPCNativeWrapper
let xpcXPathResult = helper.xrayWindow.XPathResult;
test.assertEqual(xpcXPathResult.wrappedJSObject.
UNORDERED_NODE_SNAPSHOT_TYPE,
value,
"XPathResult's constants are valid on unwrapped node");

test.assertEqual(xpcXPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, 6,
"XPathResult's constants are defined on " +
"XPCNativeWrapper (platform bug #)");
XPathResultTypes.forEach(function(type, i) {
test.assertEqual(xpcXPathResult.wrappedJSObject[type],
helper.rawWindow.XPathResult[type],
"XPathResult's constants are valid on unwrapped node");

test.assertEqual(xpcXPathResult[type], i,
"XPathResult's constants are defined on " +
"XPCNativeWrapper (platform bug #)");
});

let value = helper.rawWindow.XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE;
let worker = helper.createWorker(
'new ' + function ContentScriptScope() {
self.port.on("value", function (value) {
Expand All @@ -663,7 +672,6 @@ exports.testXPathResult = createProxyTest("", function (helper, test) {
}
);
worker.port.emit("value", value);

});

exports.testPrototypeInheritance = createProxyTest("", function (helper) {
Expand Down

0 comments on commit 53a51a0

Please sign in to comment.