Bug 943006 - Update Shumway to version 0.7.806. r=till

This commit is contained in:
Yury Delendik 2013-11-26 08:16:32 -06:00
Родитель ec59b7653a
Коммит c00ed4e57c
9 изменённых файлов: 5099 добавлений и 5899 удалений

Просмотреть файл

@ -72,7 +72,8 @@ function log(aMsg) {
}
function getDOMWindow(aChannel) {
var requestor = aChannel.notificationCallbacks;
var requestor = aChannel.notificationCallbacks ||
aChannel.loadGroup.notificationCallbacks;
var win = requestor.getInterface(Components.interfaces.nsIDOMWindow);
return win;
}
@ -177,7 +178,10 @@ function isShumwayEnabledFor(actions) {
// blacklisting well known sites with issues
if (/\.ytimg\.com\//i.test(url) /* youtube movies */ ||
/\/vui.swf\b/i.test(url) /* vidyo manager */ ) {
/\/vui.swf\b/i.test(url) /* vidyo manager */ ||
/soundcloud\.com\/player\/assets\/swf/i.test(url) /* soundcloud */ ||
/sndcdn\.com\/assets\/swf/.test(url) /* soundcloud */ ||
/vimeocdn\.com/.test(url) /* vimeo */) {
return false;
}
@ -727,34 +731,45 @@ ShumwayStreamConverterBase.prototype = {
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
},
isValidRequest: function() {
return true;
},
getUrlHint: function(requestUrl) {
return requestUrl.spec;
},
createChromeActions: function(window, document, urlHint) {
var url;
var url = urlHint;
var baseUrl;
var pageUrl;
var element = window.frameElement;
var isOverlay = false;
var objectParams = {};
if (element) {
var tagName = element.nodeName;
// PlayPreview overlay "belongs" to the embed/object tag and consists of
// DIV and IFRAME. Starting from IFRAME and looking for first object tag.
var tagName = element.nodeName, containerElement;
while (tagName != 'EMBED' && tagName != 'OBJECT') {
// plugin overlay skipping until the target plugin is found
isOverlay = true;
containerElement = element;
element = element.parentNode;
if (!element)
throw 'Plugin element is not found';
if (!element) {
throw new Error('Plugin element is not found');
}
tagName = element.nodeName;
}
// TODO: remove hack once bug 920927 is fixed
element.style.visibility = 'visible';
if (isOverlay) {
// Checking if overlay is a proper PlayPreview overlay.
for (var i = 0; i < element.children.length; i++) {
if (element.children[i] === containerElement) {
throw new Error('Plugin element is invalid');
}
}
}
}
if (element) {
// Getting absolute URL from the EMBED tag
url = element.srcURI.spec;
pageUrl = element.ownerDocument.location.href; // proper page url?
@ -764,7 +779,6 @@ ShumwayStreamConverterBase.prototype = {
objectParams[paramName] = element.attributes[i].value;
}
} else {
url = element.getAttribute('data');
for (var i = 0; i < element.childNodes.length; ++i) {
var paramElement = element.childNodes[i];
if (paramElement.nodeType != 1 ||
@ -777,7 +791,10 @@ ShumwayStreamConverterBase.prototype = {
}
}
url = url || objectParams.src || objectParams.movie;
if (!url) { // at this point url shall be known -- asserting
throw new Error('Movie url is not specified');
}
baseUrl = objectParams.base || pageUrl;
var movieParams = {};
@ -794,9 +811,6 @@ ShumwayStreamConverterBase.prototype = {
}
}
url = !url ? urlHint : Services.io.newURI(url, null,
baseUrl ? Services.io.newURI(baseUrl, null, null) : null).spec;
var allowScriptAccess = false;
switch (objectParams.allowscriptaccess || 'sameDomain') {
case 'always':
@ -830,9 +844,6 @@ ShumwayStreamConverterBase.prototype = {
// nsIStreamConverter::asyncConvertData
asyncConvertData: function(aFromType, aToType, aListener, aCtxt) {
if(!this.isValidRequest(aCtxt))
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
// Store the listener passed to us
this.listener = aListener;
},
@ -847,8 +858,15 @@ ShumwayStreamConverterBase.prototype = {
onStartRequest: function(aRequest, aContext) {
// Setup the request so we can use it below.
aRequest.QueryInterface(Ci.nsIChannel);
// Cancel the request so the viewer can handle it.
aRequest.cancel(Cr.NS_BINDING_ABORTED);
aRequest.QueryInterface(Ci.nsIWritablePropertyBag);
// Change the content type so we don't get stuck in a loop.
aRequest.setProperty('contentType', aRequest.contentType);
aRequest.contentType = 'text/html';
// TODO For now suspending request, however we can continue fetching data
aRequest.suspend();
var originalURI = aRequest.URI;
@ -857,61 +875,74 @@ ShumwayStreamConverterBase.prototype = {
getBoolPref('shumway.simpleMode', false);
// Create a new channel that loads the viewer as a resource.
var channel = Services.io.newChannel(isSimpleMode ?
var viewerUrl = isSimpleMode ?
'resource://shumway/web/simple.html' :
'resource://shumway/web/viewer.html', null, null);
'resource://shumway/web/viewer.html';
var channel = Services.io.newChannel(viewerUrl, null, null);
var converter = this;
var listener = this.listener;
// Proxy all the request observer calls, when it gets to onStopRequest
// we can get the dom window.
var proxy = {
onStartRequest: function() {
listener.onStartRequest.apply(listener, arguments);
onStartRequest: function(request, context) {
listener.onStartRequest(aRequest, context);
},
onDataAvailable: function() {
listener.onDataAvailable.apply(listener, arguments);
onDataAvailable: function(request, context, inputStream, offset, count) {
listener.onDataAvailable(aRequest, context, inputStream, offset, count);
},
onStopRequest: function() {
onStopRequest: function(request, context, statusCode) {
// Cancel the request so the viewer can handle it.
aRequest.resume();
aRequest.cancel(Cr.NS_BINDING_ABORTED);
var domWindow = getDOMWindow(channel);
if (domWindow.document.documentURIObject.equals(channel.originalURI)) {
// Double check the url is still the correct one.
let actions = converter.createChromeActions(domWindow,
domWindow.document,
converter.getUrlHint(originalURI));
if (!isShumwayEnabledFor(actions)) {
actions.fallback(true);
return;
}
let actions = converter.createChromeActions(domWindow,
domWindow.document,
converter.getUrlHint(originalURI));
// Report telemetry on amount of swfs on the page
if (actions.isOverlay) {
// Looking for last actions with same baseUrl
var prevPageActions = ActivationQueue.findLastOnPage(actions.baseUrl);
var pageIndex = !prevPageActions ? 1 : (prevPageActions.telemetry.pageIndex + 1);
actions.telemetry.pageIndex = pageIndex;
ShumwayTelemetry.onPageIndex(pageIndex);
} else {
ShumwayTelemetry.onPageIndex(0);
}
actions.activationCallback = function(domWindow, isSimpleMode) {
delete this.activationCallback;
activateShumwayScripts(domWindow, isSimpleMode);
}.bind(actions, domWindow, isSimpleMode);
ActivationQueue.enqueue(actions);
let requestListener = new RequestListener(actions);
domWindow.addEventListener('shumway.message', function(event) {
requestListener.receive(event);
}, false, true);
if (!isShumwayEnabledFor(actions)) {
actions.fallback(true);
return;
}
listener.onStopRequest.apply(listener, arguments);
// Report telemetry on amount of swfs on the page
if (actions.isOverlay) {
// Looking for last actions with same baseUrl
var prevPageActions = ActivationQueue.findLastOnPage(actions.baseUrl);
var pageIndex = !prevPageActions ? 1 : (prevPageActions.telemetry.pageIndex + 1);
actions.telemetry.pageIndex = pageIndex;
ShumwayTelemetry.onPageIndex(pageIndex);
} else {
ShumwayTelemetry.onPageIndex(0);
}
actions.activationCallback = function(domWindow, isSimpleMode) {
delete this.activationCallback;
activateShumwayScripts(domWindow, isSimpleMode);
}.bind(actions, domWindow, isSimpleMode);
ActivationQueue.enqueue(actions);
let requestListener = new RequestListener(actions);
domWindow.addEventListener('shumway.message', function(event) {
requestListener.receive(event);
}, false, true);
listener.onStopRequest(aRequest, context, statusCode);
}
};
// XXX? Keep the URL the same so the browser sees it as the same.
// channel.originalURI = aRequest.URI;
// Keep the URL the same so the browser sees it as the same.
channel.originalURI = aRequest.URI;
channel.loadGroup = aRequest.loadGroup;
// We can use resource principal when data is fetched by the chrome
// e.g. useful for NoScript
var securityManager = Cc['@mozilla.org/scriptsecuritymanager;1']
.getService(Ci.nsIScriptSecurityManager);
var uri = Services.io.newURI(viewerUrl, null, null);
var resourcePrincipal = securityManager.getNoAppCodebasePrincipal(uri);
aRequest.owner = resourcePrincipal;
channel.asyncOpen(proxy, aContext);
},
@ -943,17 +974,6 @@ copyProperties(ShumwayStreamOverlayConverter.prototype, {
classDescription: 'Shumway PlayPreview Component',
contractID: '@mozilla.org/streamconv;1?from=application/x-moz-playpreview&to=*/*'
});
ShumwayStreamOverlayConverter.prototype.isValidRequest =
(function(aCtxt) {
try {
var request = aCtxt;
request.QueryInterface(Ci.nsIChannel);
var spec = request.URI.spec;
return spec.indexOf(EXPECTED_PLAYPREVIEW_URI_PREFIX) === 0;
} catch (e) {
return false;
}
});
ShumwayStreamOverlayConverter.prototype.getUrlHint = function (requestUrl) {
return '';
};

Двоичный файл не отображается.

Двоичный файл не отображается.

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Просмотреть файл

@ -1 +1 @@
0.7.502
0.7.806

Просмотреть файл

@ -120,6 +120,8 @@ function runViewer() {
}
var showURLMenu = document.getElementById('showURLMenu');
showURLMenu.addEventListener('click', showURL);
var inspectorMenu = document.getElementById('inspectorMenu');
inspectorMenu.addEventListener('click', showInInspector);
document.getElementById('copyProfileMenu').addEventListener('click', copyProfile);
}
@ -129,6 +131,15 @@ function showURL() {
window.prompt("Copy to clipboard", flashParams.url);
}
function showInInspector() {
var base = "http://www.areweflashyet.com/shumway/examples/inspector/inspector.html?rfile=";
var params = '';
for (var k in movieParams) {
params += '&' + k + '=' + encodeURIComponent(movieParams[k]);
}
window.open(base + encodeURIComponent(movieUrl) + params);
}
function copyProfile() {
function toArray(v) {
var array = [];

Просмотреть файл

@ -23,7 +23,7 @@ limitations under the License.
<script src="../lib/DataView.js/DataView.js"></script>
<!-- Load SWF Dependencies -->
<script src="../swf/util.js"></script>
<script src="../flash/util.js"></script>
<script src="../swf/inflate.js"></script>
<script src="../swf/stream.js"></script>

Просмотреть файл

@ -83,6 +83,7 @@ limitations under the License.
<menu type="context" id="shumwayMenu">
<menuitem label="Show URL" id="showURLMenu"></menuitem>
<menuitem label="Copy Profile" id="copyProfileMenu"></menuitem>
<menuitem label="Open in Inspector" id="inspectorMenu"></menuitem>
<menuitem label="Fallback to Flash" id="fallbackMenu" hidden></menuitem>
</menu>
</section>