Bug 1130737 - Update Shumway to version 0.9.3775. r=till

This commit is contained in:
Yury Delendik 2015-02-07 09:53:12 -06:00
parent 5900d85d78
commit a9f23bac36
11 changed files with 35515 additions and 35112 deletions

View File

@ -53,7 +53,8 @@ function getStringPref(pref, def) {
}
function log(str) {
dump(str + '\n');
var msg = 'ShumwayBootstrapUtils.jsm: ' + str;
Services.console.logStringMessage(msg);
}
// Register/unregister a constructor as a factory.
@ -80,6 +81,19 @@ Factory.prototype = {
let converterFactory = new Factory();
let overlayConverterFactory = new Factory();
function allowedPlatformForMedia() {
var oscpu = Cc["@mozilla.org/network/protocol;1?name=http"]
.getService(Ci.nsIHttpProtocolHandler).oscpu;
if (oscpu.indexOf('Windows NT') === 0) {
return oscpu.indexOf('Windows NT 5') < 0; // excluding Windows XP
}
if (oscpu.indexOf('Intel Mac OS X') === 0) {
return true;
}
// Other platforms are not supported yet.
return false;
}
var ShumwayBootstrapUtils = {
register: function () {
// Register the components.
@ -88,7 +102,15 @@ var ShumwayBootstrapUtils = {
if (registerOverlayPreview) {
var ignoreCTP = getBoolPref(PREF_IGNORE_CTP, true);
var whitelist = getStringPref(PREF_WHITELIST);
var whitelist = getStringPref(PREF_WHITELIST);
// Some platforms cannot support video playback, and our whitelist targets
// only video players atm. We need to disable Shumway for those platforms.
if (whitelist && !Services.prefs.prefHasUserValue(PREF_WHITELIST) &&
!allowedPlatformForMedia()) {
log('Default SWF whitelist is used on an unsupported platform -- ' +
'using demo whitelist.');
whitelist = 'http://www.areweflashyet.com/*.swf';
}
Ph.registerPlayPreviewMimeType(SWF_CONTENT_TYPE, ignoreCTP,
undefined, whitelist);
}

View File

@ -220,7 +220,7 @@ function isShumwayEnabledFor(actions) {
function getVersionInfo() {
var deferred = Promise.defer();
var versionInfo = {
version: 'unknown',
geckoVersion: 'unknown',
geckoBuildID: 'unknown',
shumwayVersion: 'unknown'
};
@ -230,18 +230,30 @@ function getVersionInfo() {
versionInfo.geckoVersion = appInfo.version;
versionInfo.geckoBuildID = appInfo.appBuildID;
} catch (e) {
log('Error encountered while getting platform version info:', e);
log('Error encountered while getting platform version info: ' + e);
}
try {
var addonId = "shumway@research.mozilla.org";
AddonManager.getAddonByID(addonId, function(addon) {
versionInfo.shumwayVersion = addon ? addon.version : 'n/a';
deferred.resolve(versionInfo);
});
} catch (e) {
log('Error encountered while getting Shumway version info:', e);
var xhr = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]
.createInstance(Ci.nsIXMLHttpRequest);
xhr.open('GET', 'resource://shumway/version.txt', true);
xhr.overrideMimeType('text/plain');
xhr.onload = function () {
try {
// Trying to merge version.txt lines into something like:
// "version (sha) details"
var lines = xhr.responseText.split(/\n/g);
lines[1] = '(' + lines[1] + ')';
versionInfo.shumwayVersion = lines.join(' ');
} catch (e) {
log('Error while parsing version info: ' + e);
}
deferred.resolve(versionInfo);
}
};
xhr.onerror = function () {
log('Error while reading version info: ' + xhr.error);
deferred.resolve(versionInfo);
};
xhr.send();
return deferred.promise;
}
@ -754,6 +766,7 @@ function activateShumwayScripts(window, requestListener) {
}
function initExternalCom(wrappedWindow, wrappedObject, targetWindow) {
var traceExternalInterface = getBoolPref('shumway.externalInterface.trace', false);
if (!wrappedWindow.__flash__initialized) {
wrappedWindow.__flash__initialized = true;
wrappedWindow.__flash__toXML = function __flash__toXML(obj) {
@ -786,29 +799,32 @@ function initExternalCom(wrappedWindow, wrappedObject, targetWindow) {
}
};
wrappedWindow.__flash__eval = function (expr) {
this.console.log('__flash__eval: ' + expr);
traceExternalInterface && this.console.log('__flash__eval: ' + expr);
// allowScriptAccess protects page from unwanted swf scripts,
// we can execute script in the page context without restrictions.
return this.eval(expr);
var result = this.eval(expr);
traceExternalInterface && this.console.log('__flash__eval (result): ' + result);
return result;
}.bind(wrappedWindow);
wrappedWindow.__flash__call = function (expr) {
this.console.log('__flash__call (ignored): ' + expr);
traceExternalInterface && this.console.log('__flash__call (ignored): ' + expr);
};
}
wrappedObject.__flash__registerCallback = function (functionName) {
wrappedWindow.console.log('__flash__registerCallback: ' + functionName);
traceExternalInterface && wrappedWindow.console.log('__flash__registerCallback: ' + functionName);
Components.utils.exportFunction(function () {
var args = Array.prototype.slice.call(arguments, 0);
wrappedWindow.console.log('__flash__callIn: ' + functionName);
traceExternalInterface && wrappedWindow.console.log('__flash__callIn: ' + functionName);
var result;
if (targetWindow.wrappedJSObject.onExternalCallback) {
result = targetWindow.wrappedJSObject.onExternalCallback({functionName: functionName, args: args});
traceExternalInterface && wrappedWindow.console.log('__flash__callIn (result): ' + result);
}
return wrappedWindow.eval(result);
}, this, { defineAs: functionName });
};
wrappedObject.__flash__unregisterCallback = function (functionName) {
wrappedWindow.console.log('__flash__unregisterCallback: ' + functionName);
traceExternalInterface && wrappedWindow.console.log('__flash__unregisterCallback: ' + functionName);
delete this[functionName];
};
}
@ -909,7 +925,11 @@ ShumwayStreamConverterBase.prototype = {
throw new Error('Movie url is not specified');
}
baseUrl = objectParams.base || pageUrl;
if (objectParams.base) {
baseUrl = Services.io.newURI(objectParams.base, null, pageUrl).spec;
} else {
baseUrl = pageUrl;
}
var movieParams = {};
if (objectParams.flashvars) {

View File

@ -17,6 +17,7 @@ var EXPORTED_SYMBOLS = ["ShumwayUtils"];
const PREF_PREFIX = 'shumway.';
const PREF_DISABLED = PREF_PREFIX + 'disabled';
const PREF_WHITELIST = PREF_PREFIX + 'swf.whitelist';
let Cc = Components.classes;
let Ci = Components.interfaces;
@ -43,6 +44,7 @@ let ShumwayUtils = {
_registered: false,
init: function init() {
this.migratePreferences();
if (this.enabled)
this._ensureRegistered();
else
@ -56,6 +58,19 @@ let ShumwayUtils = {
Services.prefs.addObserver(PREF_DISABLED, this, false);
},
migratePreferences: function migratePreferences() {
// At one point we had shumway.disabled set to true by default,
// and we are trying to replace it with shumway.swf.whitelist:
// checking if the user already changed it before to reset
// the whitelist to '*'.
if (Services.prefs.prefHasUserValue(PREF_DISABLED) &&
!Services.prefs.prefHasUserValue(PREF_WHITELIST) &&
!getBoolPref(PREF_DISABLED, false)) {
// The user is already using Shumway -- enabling all web sites.
Services.prefs.setCharPref(PREF_WHITELIST, '*');
}
},
// nsIObserver
observe: function observe(aSubject, aTopic, aData) {
if (this.enabled)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,2 +1,2 @@
0.9.3693
217e2e2
0.9.3775
a82ac47

View File

@ -111,7 +111,7 @@ limitations under the License.
<menuitem label="Open in Inspector" id="inspectorMenu"></menuitem>
<menuitem label="Report Problems" id="reportMenu"></menuitem>
<menuitem label="Reload in Adobe Flash Player" id="fallbackMenu" hidden></menuitem>
<menuitem label="About Shumway" id="aboutMenu"></menuitem>
<menuitem label="About Shumway %version%..." id="aboutMenu"></menuitem>
</menu>
</section>

View File

@ -161,6 +161,10 @@ function runViewer() {
document.getElementById('inspectorMenu').addEventListener('click', showInInspector);
document.getElementById('reportMenu').addEventListener('click', reportIssue);
document.getElementById('aboutMenu').addEventListener('click', showAbout);
var version = Shumway.version || '';
document.getElementById('aboutMenu').label =
document.getElementById('aboutMenu').label.replace('%version%', version);
}
function showURL() {

View File

@ -44,7 +44,7 @@ function runSwfPlayer(flashParams) {
Shumway.AVM2.Verifier.enabled.value = compilerSettings.verifier;
Shumway.createAVM2(builtinPath, viewerPlayerglobalInfo, sysMode, appMode, function (avm2) {
function runSWF(file) {
function runSWF(file, buffer, baseUrl) {
var player = new Shumway.Player.Window.WindowPlayer(window, window.parent);
player.defaultStageColor = flashParams.bgcolor;
player.movieParams = flashParams.movieParams;
@ -54,17 +54,18 @@ function runSwfPlayer(flashParams) {
Shumway.ExternalInterfaceService.instance = player.createExternalInterfaceService();
player.load(file);
player.pageUrl = baseUrl;
player.load(file, buffer);
}
Shumway.FileLoadingService.instance.setBaseUrl(baseUrl);
if (asyncLoading) {
runSWF(movieUrl);
runSWF(movieUrl, undefined, baseUrl);
} else {
new Shumway.BinaryFileReader(movieUrl).readAll(null, function(buffer, error) {
if (!buffer) {
throw "Unable to open the file " + movieUrl + ": " + error;
}
runSWF(movieUrl, buffer);
runSWF(movieUrl, buffer, baseUrl);
});
}
});
@ -127,6 +128,11 @@ function setupServices() {
this.onprogress && this.onprogress(args.array, {bytesLoaded: args.loaded, bytesTotal: args.total});
break;
}
},
close: function () {
if (Shumway.FileLoadingService.instance.sessions[sessionId]) {
// TODO send abort
}
}
};
},