webkit problem printing XPathResults, need workaro

2019-07-24 01:24发布

问题:

I'm using the following code...

 var result = document.evaluate(expr,context,null,9,null);

When printing the result I get the following error...

Error: TYPE_ERR: DOM XPath Exception 52

This appears to be an issue with webkit in general as evident from the following issue...

http://code.google.com/p/chromium/issues/detail?id=68770

I'm wondering, does anyone know of a workaround way I can make this work? The work around need only suit just webkit. It does not needed to work in Firefox, IE, etc.

NOTE: I myself am working with Google Chrome but I've included the other popular applications which use webkit since this issue is relevant to them too.

EDIT: Same result when I call screenshotLength() on result.

EDIT 2

var result = document.evaluate(expr,context,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;

Appears to produce undefined

回答1:

Ah! It wasn't webkit but rather the way I was calling this function. All document.evaluate calls in Chrome shouldn't be made in the background.html. Worked from a content script for me.