Merge pull request #3735 from yurydelendik/embed-base

Properly resolves relative src for the embed tags
This commit is contained in:
Brendan Dahl 2013-09-26 10:38:08 -07:00
commit ea50c078b0

View File

@ -43,50 +43,30 @@ function getDOMWindow(aChannel) {
}
function getObjectUrl(window) {
var url;
var element = window.frameElement;
var isOverlay = false;
var params = {};
if (element) {
// PlayPreview overlay "belongs" to the embed/object tag and consists of DIV
// and IFRAME. Starting from IFRAME and looking for first object tag.
var element = window.frameElement, containerElement;
if (!element) {
return null; // iframe tag
}
var tagName = element.nodeName;
while (tagName != 'EMBED' && tagName != 'OBJECT') {
// plugin overlay skipping until the target plugin is found
isOverlay = true;
while (tagName !== 'EMBED' && tagName !== 'OBJECT') {
containerElement = element;
element = element.parentNode;
if (!element)
throw 'Plugin element is not found';
if (!element) {
return null; // object tag was not found
}
tagName = element.nodeName;
}
if (tagName == 'EMBED') {
for (var i = 0; i < element.attributes.length; ++i) {
params[element.attributes[i].localName] = element.attributes[i].value;
// Checking if overlay is a proper PlayPreview overlay.
for (var i = 0; i < element.children.length; i++) {
if (element.children[i] === containerElement) {
return null; // invalid plugin element overlay
}
url = params.src;
} else {
for (var i = 0; i < element.childNodes.length; ++i) {
var paramElement = element.childNodes[i];
if (paramElement.nodeType != Ci.nsIDOMNode.ELEMENT_NODE ||
paramElement.nodeName != 'PARAM') {
continue;
}
params[paramElement.getAttribute('name')] =
paramElement.getAttribute('value');
}
var dataAttribute = element.getAttribute('data');
url = dataAttribute || params.movie || params.src;
}
}
if (!url) {
return url; // src is not specified
}
var element = window.frameElement;
// XXX base uri?
var baseUri = !element ? null :
Services.io.newURI(element.ownerDocument.location.href, null, null);
return Services.io.newURI(url, null, baseUri).spec;
return element.srcURI.spec;
}
function PdfRedirector() {