Bug 1276468 - Fix sheetToUrl function for inline style. r=jwalker

The function was trying to access `stylesheet` parameter's ownerNode property,
which is undefined when the parameter is a StyleSheetActor. In the latter case,
we use nodeHref and styleSheetIndex properties to match what is done when the
parameter is a StyleSheet.

MozReview-Commit-ID: 7FNoKasFYLL
This commit is contained in:
Nicolas Chevobbe 2016-06-06 21:48:54 +02:00
parent c37347cd35
commit 6901d27224

View File

@ -697,6 +697,7 @@ exports.SEL_ALL = [
/**
* Find a URL for a given stylesheet
* @param stylesheet {StyleSheet|StyleSheetActor}
*/
const sheetToUrl = exports.sheetToUrl = function (stylesheet) {
// For <link> elements
@ -712,5 +713,10 @@ const sheetToUrl = exports.sheetToUrl = function (stylesheet) {
return getURL(document) + " → <style> index " + index;
}
// When `stylesheet` is a StyleSheetActor, we don't have access to ownerNode
if (stylesheet.nodeHref) {
return stylesheet.nodeHref + " → <style> index " + stylesheet.styleSheetIndex;
}
throw new Error("Unknown sheet source");
};