Merge inbound to m-c. a=merge

This commit is contained in:
Ryan VanderMeulen 2014-08-12 16:24:50 -04:00
commit d5a4ba923d
1080 changed files with 54568 additions and 34782 deletions

View File

@ -22,4 +22,4 @@
# changes to stick? As of bug 928195, this shouldn't be necessary! Please
# don't change CLOBBER for WebIDL changes any more.
Bug 1046533 needs a clobber on Android.
Skia update needs a CLOBBER on all platforms.

View File

@ -193,9 +193,9 @@
var tree4acc = getAccessible("tree4");
tree4element.parentNode.removeChild(tree4element);
waitForEvent(EVENT_REORDER, tree4acc, function() {
testGroupAttrs("tree4_ti2", 1, 1, 1); });
SimpleTest.finish();
testGroupAttrs("tree4_ti2", 1, 1, 1);
SimpleTest.finish();
});
}
SimpleTest.waitForExplicitFinish();

View File

@ -389,7 +389,7 @@ function eventQueue(aEventType)
var res = this.onFinish();
if (res != DO_NOT_FINISH_TEST)
SimpleTest.finish();
SimpleTest.executeSoon(SimpleTest.finish);
return;
}

View File

@ -889,10 +889,6 @@ pref("network.sntp.timeout", 30); // In seconds.
// Enable dataStore
pref("dom.datastore.enabled", true);
// When an entry is changed, use two timers to fire system messages in a more
// moderate pattern.
pref("dom.datastore.sysMsgOnChangeShortTimeoutSec", 10);
pref("dom.datastore.sysMsgOnChangeLongTimeoutSec", 60);
// DOM Inter-App Communication API.
pref("dom.inter-app-communication-api.enabled", true);

View File

@ -571,8 +571,7 @@ let gHistorySwipeAnimation = {
return;
this.active = false;
this.isLTR = document.documentElement.mozMatchesSelector(
":-moz-locale-dir(ltr)");
this.isLTR = document.documentElement.matches(":-moz-locale-dir(ltr)");
this._trackedSnapshots = [];
this._startingIndex = -1;
this._historyIndex = -1;

View File

@ -650,7 +650,7 @@ nsContextMenu.prototype = {
else if ((this.target instanceof HTMLEmbedElement ||
this.target instanceof HTMLObjectElement ||
this.target instanceof HTMLAppletElement) &&
this.target.mozMatchesSelector(":-moz-handler-clicktoplay")) {
this.target.matches(":-moz-handler-clicktoplay")) {
this.onCTPPlugin = true;
}

View File

@ -89,6 +89,7 @@ function handleMessageEvents(event) {
break;
case 2:
is(event.data, "onupdate", "Child was successfully updated.");
clearInterval(intervalID);
finishTest();
break;
default:

View File

@ -4145,7 +4145,7 @@ OverflowableToolbar.prototype = {
this._hideTimeoutId = null;
}
this._hideTimeoutId = window.setTimeout(() => {
if (!this._panel.firstChild.mozMatchesSelector(":hover")) {
if (!this._panel.firstChild.matches(":hover")) {
this._panel.hidePopup();
}
}, OVERFLOW_PANEL_HIDE_DELAY_MS);

View File

@ -487,7 +487,7 @@ function checkContextMenu(aContextMenu, aExpectedEntries, aWindow=window) {
}
let selector = aExpectedEntries[i][0];
ok(menuitem.mozMatchesSelector(selector), "menuitem should match " + selector + " selector");
ok(menuitem.matches(selector), "menuitem should match " + selector + " selector");
let commandValue = menuitem.getAttribute("command");
let relatedCommand = commandValue ? aWindow.document.getElementById(commandValue) : null;
let menuItemDisabled = relatedCommand ?

View File

@ -587,7 +587,7 @@ gTests.push({
handleStub.restore();
}
ok(!firstItem.mozMatchesSelector("richgriditem[value]"), "Released slot doesn't match binding selector");
ok(!firstItem.matches("richgriditem[value]"), "Released slot doesn't match binding selector");
ok(isNotBoundByRichGrid_Item(firstItem), "Released slot is no longer bound");
waitForCondition(() => isNotBoundByRichGrid_Item(firstItem));

View File

@ -4141,7 +4141,6 @@ case "$MOZ_WIDGET_TOOLKIT" in
cairo-windows)
MOZ_WIDGET_TOOLKIT=windows
MOZ_WEBGL=1
MOZ_PDF_PRINTING=1
MOZ_INSTRUMENT_EVENT_LOOP=1
if test -n "$GNU_CC"; then
@ -4154,7 +4153,6 @@ cairo-gtk3)
MOZ_ENABLE_GTK=1
MOZ_ENABLE_GTK3=1
MOZ_ENABLE_XREMOTE=1
MOZ_WEBGL=1
MOZ_GL_DEFAULT_PROVIDER=GLX
AC_DEFINE(MOZ_X11)
@ -4174,7 +4172,6 @@ cairo-gtk2|cairo-gtk2-x11)
MOZ_ENABLE_GTK=1
MOZ_ENABLE_GTK2=1
MOZ_ENABLE_XREMOTE=1
MOZ_WEBGL=1
MOZ_GL_DEFAULT_PROVIDER=GLX
AC_DEFINE(MOZ_X11)
@ -4201,7 +4198,6 @@ cairo-qt)
XT_LIBS=
fi
MOZ_WEBGL=1
USE_FC_FREETYPE=1
TK_CFLAGS='$(MOZ_QT_CFLAGS)'
TK_LIBS='$(MOZ_QT_LIBS)'
@ -4222,7 +4218,6 @@ cairo-cocoa)
CXXFLAGS="$CXXFLAGS $TK_CFLAGS"
MOZ_USER_DIR="Mozilla"
MOZ_FS_LAYOUT=bundle
MOZ_WEBGL=1
MOZ_INSTRUMENT_EVENT_LOOP=1
;;
@ -4243,7 +4238,6 @@ cairo-android)
MOZ_WIDGET_TOOLKIT=android
TK_CFLAGS='$(MOZ_CAIRO_CFLAGS) $(MOZ_PIXMAN_CFLAGS)'
TK_LIBS='$(MOZ_CAIRO_LIBS) $(MOZ_PIXMAN_LIBS)'
MOZ_WEBGL=1
MOZ_PDF_PRINTING=1
MOZ_INSTRUMENT_EVENT_LOOP=1
;;
@ -4254,7 +4248,6 @@ cairo-gonk)
MOZ_WIDGET_TOOLKIT=gonk
TK_CFLAGS='$(MOZ_CAIRO_CFLAGS) $(MOZ_PIXMAN_CFLAGS)'
TK_LIBS='$(MOZ_CAIRO_LIBS) $(MOZ_PIXMAN_LIBS)'
MOZ_WEBGL=1
MOZ_PDF_PRINTING=1
MOZ_TOUCH=1
MOZ_INSTRUMENT_EVENT_LOOP=1
@ -5672,25 +5665,14 @@ x86_64)
;;
esac
MOZ_ARG_DISABLE_BOOL(webgl,
[ --disable-webgl Disable building of the WebGL implementation],
MOZ_WEBGL_DISABLED=1,
MOZ_WEBGL_DISABLED=)
MOZ_ARG_ENABLE_BOOL(require-all-d3dc-versions,
[ --enable-require-all-d3dc-versions Require all versions of the D3D compiler needed for supported Windows systems.],
MOZ_REQUIRE_ALL_D3DCS=1,
MOZ_REQUIRE_ALL_D3DCS=)
if test -n "$MOZ_WEBGL_DISABLED"; then
MOZ_WEBGL=
MOZ_ANGLE_RENDERER=
fi
if test -n "$MOZ_WEBGL"; then
AC_DEFINE(MOZ_WEBGL)
fi
# This is potentially set in external mozconfig files; if it's set,
# then the build exposes the "webgl" context name, which is reserved
# for conformant implementations.
if test -n "$MOZ_WEBGL_CONFORMANT"; then
AC_DEFINE(MOZ_WEBGL_CONFORMANT)
fi
@ -8392,7 +8374,6 @@ AC_SUBST(MOZ_SOCIAL)
AC_SUBST(MOZ_TOOLKIT_SEARCH)
AC_SUBST(MOZ_FEEDS)
AC_SUBST(NS_PRINTING)
AC_SUBST(MOZ_WEBGL)
AC_SUBST(MOZ_HELP_VIEWER)
AC_SUBST(TOOLCHAIN_PREFIX)

View File

@ -35,6 +35,10 @@ function checkDefaultSrcOnly() {
ok(getElementColorById(testframe, 'unsafe-inline-script') === green, "Inline script should be allowed");
ok(getElementColorById(testframe, 'unsafe-eval-script') === green, "Eval should be allowed");
ok(getElementColorById(testframe, 'unsafe-inline-style') === green, "Inline style should be allowed");
document.getElementById('testframe2').src = 'file_CSP_bug888172.sjs?csp=' +
escape("default-src 'self' 'unsafe-inline' 'unsafe-eval'; script-src 'self'");
document.getElementById('testframe2').addEventListener('load', checkDefaultSrcWithScriptSrc, false);
}
function checkDefaultSrcWithScriptSrc() {
@ -43,6 +47,10 @@ function checkDefaultSrcWithScriptSrc() {
ok(getElementColorById(testframe, 'unsafe-inline-script') === black, "Inline script should be blocked");
ok(getElementColorById(testframe, 'unsafe-eval-script') === black, "Eval should be blocked");
ok(getElementColorById(testframe, 'unsafe-inline-style') === green, "Inline style should be allowed");
document.getElementById('testframe3').src = 'file_CSP_bug888172.sjs?csp=' +
escape("default-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self'");
document.getElementById('testframe3').addEventListener('load', checkDefaultSrcWithStyleSrc, false);
}
function checkDefaultSrcWithStyleSrc() {
@ -59,14 +67,6 @@ function checkDefaultSrcWithStyleSrc() {
document.getElementById('testframe1').src = 'file_CSP_bug888172.sjs?csp=' +
escape("default-src 'self' 'unsafe-inline' 'unsafe-eval'");
document.getElementById('testframe1').addEventListener('load', checkDefaultSrcOnly, false);
document.getElementById('testframe2').src = 'file_CSP_bug888172.sjs?csp=' +
escape("default-src 'self' 'unsafe-inline' 'unsafe-eval'; script-src 'self'");
document.getElementById('testframe2').addEventListener('load', checkDefaultSrcWithScriptSrc, false);
document.getElementById('testframe3').src = 'file_CSP_bug888172.sjs?csp=' +
escape("default-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self'");
document.getElementById('testframe3').addEventListener('load', checkDefaultSrcWithStyleSrc, false);
</script>
</pre>
</body>

View File

@ -521,7 +521,7 @@
var key = +new Date + ":" + Math.random();
function report(item, shouldMatch) {
assert( item.mozMatchesSelector(q) === shouldMatch,
assert( item.matches(q) === shouldMatch,
item + (shouldMatch ? "does not match" : "matches")
+ " selector '" + q + "'" );
}

View File

@ -600,6 +600,7 @@ skip-if = buildapp == 'b2g' || toolkit == 'android' || e10s #TIMED_OUT, SSL_REQU
skip-if = buildapp == 'b2g' || toolkit == 'android' || e10s #TIMED_OUT, SSL_REQUIRED
[test_mozfiledataurl.html]
skip-if = buildapp == 'mulet' || buildapp == 'b2g' || toolkit == 'android' || e10s #TIMED_OUT
[test_mozMatchesSelector.html]
[test_mutationobservers.html]
skip-if = buildapp == 'b2g' || e10s # b2g(bug 901385, showmodaldialog) b2g-debug(bug 901385, showmodaldialog) b2g-desktop(bug 901385, showmodaldialog)
[test_nodelist_holes.html]

View File

@ -20,7 +20,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=562169
/** Test for Bug 562169 **/
/** Test that a newly created element has ltr directionality **/
ok(document.createElement("div").mozMatchesSelector(":-moz-dir(ltr)"),
ok(document.createElement("div").matches(":-moz-dir(ltr)"),
"Element should be ltr on creation");
</script>

View File

@ -20,7 +20,7 @@ var elmt = document.createElement("div");
var caught = false;
try {
elmt.mozMatchesSelector("!!");
elmt.matches("!!");
} catch(e) {
ok(e.name == "SyntaxError", "Error should be SyntaxError");
ok(e.code == DOMException.SYNTAX_ERR, "Error code should be SYNTAX_ERR");

View File

@ -19,11 +19,9 @@ function doTest() {
var monitor = document.getElementById("monitor");
var html = document.documentElement;
var results;
var matches = html.matchesSelector || html.mozMatchesSelector;
try {
results = "return: " +
matches.call(html, "[test!='']:sizzle") + "\n";
results = "return: " + html.matches("[test!='']:sizzle") + "\n";
} catch (e) {
results = "throws: " + e + "\n";
}

View File

@ -0,0 +1,14 @@
<!doctype html>
<meta charset=utf-8>
<title>Test for legacy mozMatchesSelector</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<div id=test></div>
<script>
test(function() {
var element = document.getElementById("test");
assert_true(element.matches("#test"), "matches");
assert_true(element.mozMatchesSelector("#test"), "mozMatchesSelector");
});
</script>

View File

@ -35,10 +35,7 @@
#include "nsNetUtil.h"
#include "nsStreamUtils.h"
#include "ActiveLayerTracker.h"
#ifdef MOZ_WEBGL
#include "WebGL2Context.h"
#endif
using namespace mozilla::layers;
using namespace mozilla::gfx;
@ -636,7 +633,7 @@ HTMLCanvasElement::GetContextHelper(const nsAString& aContextId,
ctx.forget(aContext);
return NS_OK;
}
#ifdef MOZ_WEBGL
if (WebGL2Context::IsSupported() &&
aContextId.EqualsLiteral("experimental-webgl2"))
{
@ -651,7 +648,6 @@ HTMLCanvasElement::GetContextHelper(const nsAString& aContextId,
ctx.forget(aContext);
return NS_OK;
}
#endif
NS_ConvertUTF16toUTF8 ctxId(aContextId);

View File

@ -62,7 +62,7 @@ function enter1(event) {
ok(document.mozFullScreen, "1. Should be in full-screen mode (first time)");
is(event.target, document, "2. Event target should be full-screen document #1");
is(document.mozFullScreenElement, fullScreenElement(), "3. Full-screen element should be div element.");
ok(document.mozFullScreenElement.mozMatchesSelector(":-moz-full-screen"), "4. FSE should match :-moz-full-screen");
ok(document.mozFullScreenElement.matches(":-moz-full-screen"), "4. FSE should match :-moz-full-screen");
var fse = fullScreenElement();
addFullscreenChangeContinuation("exit", exit1);
fse.parentNode.removeChild(fse);
@ -158,9 +158,9 @@ function enter4(event) {
var n = container;
do {
ok(n.mozMatchesSelector(":-moz-full-screen-ancestor"), "Ancestor " + n + " should match :-moz-full-screen-ancestor")
ok(n.matches(":-moz-full-screen-ancestor"), "Ancestor " + n + " should match :-moz-full-screen-ancestor")
n = n.parentNode;
} while (n && n.mozMatchesSelector);
} while (n && n.matches);
// Remove full-screen ancestor element from document, verify it stops being reported as current FSE.
addFullscreenChangeContinuation("exit", exit4);

View File

@ -43,7 +43,7 @@ function checkValidEmailAddress(element)
ok(!gInvalid, "The invalid event should not have been thrown");
is(element.validationMessage, '',
"Validation message should be the empty string");
ok(element.mozMatchesSelector(":valid"), ":valid pseudo-class should apply");
ok(element.matches(":valid"), ":valid pseudo-class should apply");
}
function checkInvalidEmailAddress(element)
@ -56,7 +56,7 @@ function checkInvalidEmailAddress(element)
ok(gInvalid, "The invalid event should have been thrown");
is(element.validationMessage, "Please enter an email address.",
"Validation message is not valid");
ok(element.mozMatchesSelector(":invalid"), ":invalid pseudo-class should apply");
ok(element.matches(":invalid"), ":invalid pseudo-class should apply");
}
function testEmailAddress(aElement, aValue, aMultiple, aValidity)

View File

@ -78,7 +78,7 @@ function checkIsValid(element, infoStr)
ok(!gInvalid, "The invalid event should not have been thrown for " + infoStr);
is(element.validationMessage, '',
"Validation message should be the empty string for " + infoStr);
ok(element.mozMatchesSelector(":valid"), ":valid pseudo-class should apply for " + infoStr);
ok(element.matches(":valid"), ":valid pseudo-class should apply for " + infoStr);
}
function checkIsInvalid(element, infoStr)
@ -90,7 +90,7 @@ function checkIsInvalid(element, infoStr)
ok(gInvalid, "The invalid event should have been thrown for " + infoStr);
is(element.validationMessage, "Please enter a number.",
"Validation message is not the expected message for " + infoStr);
ok(element.mozMatchesSelector(":invalid"), ":invalid pseudo-class should apply for " + infoStr);
ok(element.matches(":invalid"), ":invalid pseudo-class should apply for " + infoStr);
}
</script>

View File

@ -35,7 +35,7 @@ function checkValidURL(element)
ok(!gInvalid, "The invalid event should not have been thrown");
is(element.validationMessage, '',
"Validation message should be the empty string");
ok(element.mozMatchesSelector(":valid"), ":valid pseudo-class should apply");
ok(element.matches(":valid"), ":valid pseudo-class should apply");
}
function checkInvalidURL(element)
@ -48,7 +48,7 @@ function checkInvalidURL(element)
ok(gInvalid, "The invalid event should have been thrown");
is(element.validationMessage, "Please enter a URL.",
"Validation message should be related to invalid URL");
ok(element.mozMatchesSelector(":invalid"),
ok(element.matches(":invalid"),
":invalid pseudo-class should apply");
}

View File

@ -76,19 +76,19 @@ function checkValidity(aElement, aValidity, aApply, aRangeApply)
is(aElement.validationMessage,
aValidity ? "" : overflowMsg, "Checking range overflow validation message");
is(aElement.mozMatchesSelector(":valid"), aElement.willValidate && aValidity,
is(aElement.matches(":valid"), aElement.willValidate && aValidity,
(aElement.willValidate && aValidity) ? ":valid should apply" : "valid shouldn't apply");
is(aElement.mozMatchesSelector(":invalid"), aElement.willValidate && !aValidity,
is(aElement.matches(":invalid"), aElement.willValidate && !aValidity,
(aElement.wil && aValidity) ? ":invalid shouldn't apply" : "valid should apply");
if (!aRangeApply) {
ok(!aElement.mozMatchesSelector(":in-range"), ":in-range should not match");
ok(!aElement.mozMatchesSelector(":out-of-range"),
ok(!aElement.matches(":in-range"), ":in-range should not match");
ok(!aElement.matches(":out-of-range"),
":out-of-range should not match");
} else {
is(aElement.mozMatchesSelector(":in-range"), aValidity,
is(aElement.matches(":in-range"), aValidity,
":in-range matches status should be " + aValidity);
is(aElement.mozMatchesSelector(":out-of-range"), !aValidity,
is(aElement.matches(":out-of-range"), !aValidity,
":out-of-range matches status should be " + !aValidity);
}
}

View File

@ -25,7 +25,7 @@ function checkOptimum(aElement, aValue, aOptimum, expectedResult)
aElement.setAttribute('value', aValue);
aElement.setAttribute('optimum', aOptimum);
is(aElement.mozMatchesSelector(":-moz-meter-optimum"),
is(aElement.matches(":-moz-meter-optimum"),
expectedResult, errorString);
}
@ -37,7 +37,7 @@ function checkSubOptimum(aElement, aValue, aOptimum, expectedResult)
}
aElement.setAttribute('value', aValue);
aElement.setAttribute('optimum', aOptimum);
is(aElement.mozMatchesSelector(":-moz-meter-sub-optimum"),
is(aElement.matches(":-moz-meter-sub-optimum"),
expectedResult, errorString);
}
@ -49,7 +49,7 @@ function checkSubSubOptimum(aElement, aValue, aOptimum, expectedResult)
}
aElement.setAttribute('value', aValue);
aElement.setAttribute('optimum', aOptimum);
is(aElement.mozMatchesSelector(":-moz-meter-sub-sub-optimum"),
is(aElement.matches(":-moz-meter-sub-sub-optimum"),
expectedResult, errorString);
}

View File

@ -76,19 +76,19 @@ function checkValidity(aElement, aValidity, aApply, aRangeApply)
is(aElement.validationMessage,
aValidity ? "" : underflowMsg, "Checking range underflow validation message");
is(aElement.mozMatchesSelector(":valid"), aElement.willValidate && aValidity,
is(aElement.matches(":valid"), aElement.willValidate && aValidity,
(aElement.willValidate && aValidity) ? ":valid should apply" : "valid shouldn't apply");
is(aElement.mozMatchesSelector(":invalid"), aElement.willValidate && !aValidity,
is(aElement.matches(":invalid"), aElement.willValidate && !aValidity,
(aElement.wil && aValidity) ? ":invalid shouldn't apply" : "valid should apply");
if (!aRangeApply) {
ok(!aElement.mozMatchesSelector(":in-range"), ":in-range should not match");
ok(!aElement.mozMatchesSelector(":out-of-range"),
ok(!aElement.matches(":in-range"), ":in-range should not match");
ok(!aElement.matches(":out-of-range"),
":out-of-range should not match");
} else {
is(aElement.mozMatchesSelector(":in-range"), aValidity,
is(aElement.matches(":in-range"), aValidity,
":in-range matches status should be " + aValidity);
is(aElement.mozMatchesSelector(":out-of-range"), !aValidity,
is(aElement.matches(":out-of-range"), !aValidity,
":out-of-range matches status should be " + !aValidity);
}
}

View File

@ -111,8 +111,8 @@ testCases.forEach(function(testCase) {
var option = content.querySelector('option');
is(option.getAttribute('disabled'), result.attr, "disabled content attribute value should be " + result.attr);
is(option.disabled, result.idl, "disabled idl attribute value should be " + result.idl);
is(option.mozMatchesSelector(":disabled"), result.pseudo, ":disabled state should be " + result.pseudo);
is(option.mozMatchesSelector(":enabled"), !result.pseudo, ":enabled state should be " + !result.pseudo);
is(option.matches(":disabled"), result.pseudo, ":disabled state should be " + result.pseudo);
is(option.matches(":enabled"), !result.pseudo, ":enabled state should be " + !result.pseudo);
content.innerHTML = "";
});

View File

@ -187,7 +187,7 @@ function checkIndeterminatePseudoClass()
aElement.removeAttribute('max');
}
is(aElement.mozMatchesSelector("progress:indeterminate"), aIndeterminate,
is(aElement.matches("progress:indeterminate"), aIndeterminate,
"<progress> indeterminate state should be " + aIndeterminate);
}

View File

@ -30,15 +30,15 @@ function checkNotSufferingFromBeingMissing(element, doNotApply)
"Validation message should be the empty string");
if (doNotApply) {
ok(!element.mozMatchesSelector(':valid'), ":valid should not apply");
ok(!element.mozMatchesSelector(':invalid'), ":invalid should not apply");
ok(!element.mozMatchesSelector(':-moz-ui-valid'), ":-moz-ui-valid should not apply");
ok(!element.mozMatchesSelector(':-moz-ui-invalid'), ":-moz-ui-invalid should not apply");
ok(!element.matches(':valid'), ":valid should not apply");
ok(!element.matches(':invalid'), ":invalid should not apply");
ok(!element.matches(':-moz-ui-valid'), ":-moz-ui-valid should not apply");
ok(!element.matches(':-moz-ui-invalid'), ":-moz-ui-invalid should not apply");
} else {
ok(element.mozMatchesSelector(':valid'), ":valid should apply");
ok(!element.mozMatchesSelector(':invalid'), ":invalid should not apply");
ok(element.mozMatchesSelector(':-moz-ui-valid'), ":-moz-ui-valid should apply");
ok(!element.mozMatchesSelector(':-moz-ui-invalid'), ":-moz-ui-invalid should not apply");
ok(element.matches(':valid'), ":valid should apply");
ok(!element.matches(':invalid'), ":invalid should not apply");
ok(element.matches(':-moz-ui-valid'), ":-moz-ui-valid should apply");
ok(!element.matches(':-moz-ui-invalid'), ":-moz-ui-invalid should not apply");
}
}
@ -73,10 +73,10 @@ function checkSufferingFromBeingMissing(element, hasMozUIInvalid)
"Validation message is wrong");
}
ok(!element.mozMatchesSelector(':valid'), ":valid should apply");
ok(element.mozMatchesSelector(':invalid'), ":invalid should not apply");
ok(!element.mozMatchesSelector(':-moz-ui-valid'), ":-moz-ui-valid should not apply");
is(element.mozMatchesSelector(':-moz-ui-invalid'), hasMozUIInvalid, ":-moz-ui-invalid expected state is " + hasMozUIInvalid);
ok(!element.matches(':valid'), ":valid should apply");
ok(element.matches(':invalid'), ":invalid should not apply");
ok(!element.matches(':-moz-ui-valid'), ":-moz-ui-valid should not apply");
is(element.matches(':-moz-ui-invalid'), hasMozUIInvalid, ":-moz-ui-invalid expected state is " + hasMozUIInvalid);
}
function checkTextareaRequiredValidity()

View File

@ -81,9 +81,9 @@ function checkValidity(aElement, aValidity, aApply, aData)
}
}
is(aElement.mozMatchesSelector(":valid"), aElement.willValidate && aValidity,
is(aElement.matches(":valid"), aElement.willValidate && aValidity,
(aElement.willValidate && aValidity) ? ":valid should apply" : "valid shouldn't apply");
is(aElement.mozMatchesSelector(":invalid"), aElement.willValidate && !aValidity,
is(aElement.matches(":invalid"), aElement.willValidate && !aValidity,
(aElement.wil && aValidity) ? ":invalid shouldn't apply" : "valid should apply");
}

View File

@ -25,19 +25,19 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=598833
/** Test for Bug 598833 **/
var s = $("s");
is(s.mozMatchesSelector(":invalid"), false, "Disabled select should not be invalid");
is(s.mozMatchesSelector(":valid"), false, "Disabled select should not be valid");
is(s.matches(":invalid"), false, "Disabled select should not be invalid");
is(s.matches(":valid"), false, "Disabled select should not be valid");
var p = s.parentNode;
p.removeChild(s);
is(s.mozMatchesSelector(":invalid"), true,
is(s.matches(":invalid"), true,
"Required valueless select not in tree should be invalid");
is(s.mozMatchesSelector(":valid"), false,
is(s.matches(":valid"), false,
"Required valueless select not in tree should not be valid");
p.appendChild(s);
p.disabled = false;
is(s.mozMatchesSelector(":invalid"), true,
is(s.matches(":invalid"), true,
"Required valueless select should be invalid");
is(s.mozMatchesSelector(":valid"), false,
is(s.matches(":valid"), false,
"Required valueless select should not be valid");
</script>
</pre>

View File

@ -37,8 +37,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=605124
function checkPseudoClass(aElement, aExpected)
{
is(aElement.mozMatchesSelector(":-moz-ui-invalid"), aExpected,
"mozMatchesSelector(':-moz-ui-invalid') should return " + aExpected + " for " + aElement);
is(aElement.matches(":-moz-ui-invalid"), aExpected,
"matches(':-moz-ui-invalid') should return " + aExpected + " for " + aElement);
}
var os = SpecialPowers.Cc['@mozilla.org/observer-service;1']

View File

@ -31,8 +31,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=605124
function checkPseudoClass(aElement, aExpected)
{
is(aElement.mozMatchesSelector(":-moz-ui-invalid"), aExpected,
"mozMatchesSelector(':-moz-ui-invalid') should return " + aExpected + " for " + aElement);
is(aElement.matches(":-moz-ui-invalid"), aExpected,
"matches(':-moz-ui-invalid') should return " + aExpected + " for " + aElement);
}
function checkElement(aElement)

View File

@ -43,8 +43,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=605125
function checkPseudoClass(aElement, aExpected)
{
is(aElement.mozMatchesSelector(":-moz-ui-valid"), aExpected,
"mozMatchesSelector(':-moz-ui-valid') should return " + aExpected + " for " + aElement);
is(aElement.matches(":-moz-ui-valid"), aExpected,
"matches(':-moz-ui-valid') should return " + aExpected + " for " + aElement);
}
var os = SpecialPowers.Cc['@mozilla.org/observer-service;1']

View File

@ -31,8 +31,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=605125
function checkPseudoClass(aElement, aExpected)
{
is(aElement.mozMatchesSelector(":-moz-ui-valid"), aExpected,
"mozMatchesSelector(':-moz-ui-valid') should return " + aExpected + " for " + aElement);
is(aElement.matches(":-moz-ui-valid"), aExpected,
"matches(':-moz-ui-valid') should return " + aExpected + " for " + aElement);
}
function checkElement(aElement)

View File

@ -29,15 +29,15 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=610687
function checkPseudoClasses(aElement, aValid, aValidUI, aInvalidUI)
{
if (aValid) {
ok(aElement.mozMatchesSelector(":valid"), ":valid should apply");
ok(aElement.matches(":valid"), ":valid should apply");
} else {
ok(aElement.mozMatchesSelector(":invalid"), ":invalid should apply");
ok(aElement.matches(":invalid"), ":invalid should apply");
}
is(aElement.mozMatchesSelector(":-moz-ui-valid"), aValidUI,
is(aElement.matches(":-moz-ui-valid"), aValidUI,
aValid ? ":-moz-ui-valid should apply" : ":-moz-ui-valid should not apply");
is(aElement.mozMatchesSelector(":-moz-ui-invalid"), aInvalidUI,
is(aElement.matches(":-moz-ui-invalid"), aInvalidUI,
aInvalidUI ? ":-moz-ui-invalid should apply" : ":-moz-ui-invalid should not apply");
if (aInvalidUI && (aValid || aValidUI)) {

View File

@ -34,9 +34,9 @@ function runTest()
isnot(select.selectedIndex, -1, "Something should have been selected");
ok(!select.mozMatchesSelector(":-moz-ui-valid"),
ok(!select.matches(":-moz-ui-valid"),
":-moz-ui-valid should not apply");
todo(!select.mozMatchesSelector(":-moz-ui-invalid"),
todo(!select.matches(":-moz-ui-invalid"),
":-moz-ui-invalid should not apply");
SimpleTest.finish();

View File

@ -24,7 +24,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=619278
function doElementMatchesSelector(aElement, aSelector)
{
ok(aElement.mozMatchesSelector(aSelector),
ok(aElement.matches(aSelector),
aSelector + " should match for " + aElement);
}

View File

@ -29,9 +29,9 @@ if (navigator.platform.startsWith("Win")) {
function checkSelectors(aElement)
{
ok(aElement.mozMatchesSelector(":-moz-ui-invalid"),
ok(aElement.matches(":-moz-ui-invalid"),
":-moz-ui-invalid should match for " + aElement);
ok(!aElement.mozMatchesSelector(":-moz-ui-valid"),
ok(!aElement.matches(":-moz-ui-valid"),
":-moz-ui-valid should not match for " + aElement);
}

View File

@ -33,10 +33,10 @@ var button = form.elements[3];
function checkPseudoClasses(aElement, aValid, aInvalid)
{
is(aElement.mozMatchesSelector(":-moz-ui-valid"), aValid,
is(aElement.matches(":-moz-ui-valid"), aValid,
aValid ? aElement + " should match :-moz-ui-valid"
: aElement + " should not match :-moz-ui-valid");
is(aElement.mozMatchesSelector(":-moz-ui-invalid"), aInvalid,
is(aElement.matches(":-moz-ui-invalid"), aInvalid,
aInvalid ? aElement + " should match :-moz-ui-invalid"
: aElement + " should not match :-moz-ui-invalid");
if (aValid && aInvalid) {

View File

@ -19,10 +19,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=787134
var div = document.createElement('div');
div.innerHTML = '<a href=#></a>';
var a = div.firstChild;
ok(a.mozMatchesSelector(':link'), "Should match a link not in a document");
ok(a.matches(':link'), "Should match a link not in a document");
is(div.querySelector(':link'), a, "Should find a link not in a document");
a = document.querySelector('#link-test1');
ok(a.mozMatchesSelector(':link'), "Should match a link in a document with an invalid URL");
ok(a.matches(':link'), "Should match a link in a document with an invalid URL");
</script>
</pre>
</body>

View File

@ -8,7 +8,7 @@ var gSmallTests = [
{ name:"small-shot.ogg", type:"audio/ogg", duration:0.276 },
{ name:"small-shot.m4a", type:"audio/mp4", duration:0.29 },
{ name:"small-shot.mp3", type:"audio/mpeg", duration:0.27 },
// { name:"small-shot-mp3.mp4", type:"audio/mp4; codecs=mp3", duration:0.34 },
{ name:"small-shot-mp3.mp4", type:"audio/mp4; codecs=mp3", duration:0.34 },
{ name:"r11025_s16_c1.wav", type:"audio/x-wav", duration:1.0 },
{ name:"320x240.ogv", type:"video/ogg", width:320, height:240, duration:0.266 },
{ name:"seek.webm", type:"video/webm", width:320, height:240, duration:3.966 },

View File

@ -28,6 +28,12 @@ function gotPlayEvent(event) {
" tokens["+v._state+"]=" + tokens[v._state] +
" tokens["+v._state+"].indexOf(event.type)=" + tokens[v._state].indexOf(event.type));
v._state = event.type;
if (event.type == 'canplaythrough') {
//canplaythrough event can fire multiple times on Windows
v.removeEventListener('canplaythrough', gotPlayEvent, false);
v.pause();
goToNext(v);
}
}
function goToNext(v) {
@ -46,8 +52,6 @@ function initTest(test, token) {
v.addEventListener(e, gotPlayEvent, false);
});
setTimeout(function() goToNext(v), 500);
v.src = test.name;
v.autoplay = true;
document.body.appendChild(v); // Causes load.

View File

@ -25,6 +25,9 @@ SpecialPowers.pushPrefEnv({"set": [["media.ogg.enabled", false]]},
ok(onErrorFired, 'onStop after onError');
ok(ondataavailableFired, 'ondataavailableFired');
//Apparently, as soon as the document is unloading, mediaRecorder.ondataavailable
//fires again, so set it to null to avoid failures
mediaRecorder.ondataavailable = null;
SimpleTest.finish();
}
mediaRecorder.ondataavailable = function(evt) {

View File

@ -67,6 +67,14 @@ function startTest() {
element.onended = null;
element.onplaying = null;
element.onpause = null;
//This helps to prevent these events from firing after SimpleTest.finish()
//on B2G ICS Emulator, but not sure they have been run at all, then
element.audioTracks.onremovetrack = null;
element.audioTracks.onaddtrack = null;
element.audioTracks.onchange = null;
element.videoTracks.onremovetrack = null;
element.videoTracks.onaddtrack = null;
element.videoTracks.onchange = null;
SimpleTest.finish();
}

View File

@ -85,12 +85,6 @@ var tests = [
next();
}
req.continue();
try {
req.continue();
ok(false, "calling continue twice should fail");
} catch (e) {
ok(true, "calling continue twice should fail");
}
},
function() {
// FireDone

View File

@ -1907,6 +1907,27 @@ NormalizeScalarValueString(JSContext* aCx, nsAString& aString);
void
NormalizeScalarValueString(JSContext* aCx, binding_detail::FakeString& aString);
template<typename T>
inline bool
ConvertIdToString(JSContext* cx, JS::HandleId id, T& result, bool& isSymbol)
{
if (MOZ_LIKELY(JSID_IS_STRING(id))) {
if (!AssignJSString(cx, result, JSID_TO_STRING(id))) {
return false;
}
} else if (JSID_IS_SYMBOL(id)) {
isSymbol = true;
return true;
} else {
JS::RootedValue nameVal(cx, js::IdToValue(id));
if (!ConvertJSValueToString(cx, nameVal, eStringify, eStringify, result)) {
return false;
}
}
isSymbol = false;
return true;
}
bool
ConvertJSValueToByteString(JSContext* cx, JS::Handle<JS::Value> v,
bool nullable, nsACString& result);

View File

@ -4042,12 +4042,14 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
// string.
curId = ids[i];
binding_detail::FakeString propName;
if (!JS_GetPropertyById(cx, mozMapObj, curId, &temp) ||
!JS_IdToValue(cx, curId, &propNameValue) ||
!ConvertJSValueToString(cx, propNameValue, eStringify,
eStringify, propName)) {
bool isSymbol;
if (!ConvertIdToString(cx, curId, propName, isSymbol) ||
(!isSymbol && !JS_GetPropertyById(cx, mozMapObj, curId, &temp))) {
$*{exceptionCode}
}
if (isSymbol) {
continue;
}
${valueType}* slotPtr = mozMap.AddEntry(propName);
if (!slotPtr) {
@ -5964,10 +5966,15 @@ class CGCallGenerator(CGThing):
errorReport should be a CGThing for an error report or None if no
error reporting is needed.
resultVar: If the returnType is not void, then the result of the call is
stored in a C++ variable named by resultVar. The caller is responsible for
declaring the result variable. If the caller doesn't care about the result
value, resultVar can be omitted.
"""
def __init__(self, errorReport, arguments, argsPre, returnType,
extendedAttributes, descriptorProvider, nativeMethodName,
static, object="self", argsPost=[]):
static, object="self", argsPost=[], resultVar=None):
CGThing.__init__(self)
assert errorReport is None or isinstance(errorReport, CGThing)
@ -6018,13 +6025,18 @@ class CGCallGenerator(CGThing):
arg = CGWrapper(arg, pre="NonNullHelper(", post=")")
args.append(arg)
needResultDecl = False
# Return values that go in outparams go here
if resultOutParam is not None:
if resultOutParam is "ref":
args.append(CGGeneric("result"))
if resultVar is None:
needResultDecl = True
resultVar = "result"
if resultOutParam == "ref":
args.append(CGGeneric(resultVar))
else:
assert resultOutParam is "ptr"
args.append(CGGeneric("&result"))
assert resultOutParam == "ptr"
args.append(CGGeneric("&" + resultVar))
if isFallible:
args.append(CGGeneric("rv"))
@ -6037,17 +6049,21 @@ class CGCallGenerator(CGThing):
if not static:
call = CGWrapper(call, pre="%s->" % object)
call = CGList([call, CGWrapper(args, pre="(", post=");\n")])
if result is not None:
if resultVar is None and result is not None:
needResultDecl = True
resultVar = "result"
if needResultDecl:
if resultRooter is not None:
self.cgRoot.prepend(resultRooter)
if resultArgs is not None:
resultArgs = "(%s)" % resultArgs
else:
resultArgs = ""
result = CGWrapper(result, post=(" result%s;\n" % resultArgs))
result = CGWrapper(result, post=(" %s%s;\n" % (resultVar, resultArgs)))
self.cgRoot.prepend(result)
if not resultOutParam:
call = CGWrapper(call, pre="result = ")
call = CGWrapper(call, pre=resultVar + " = ")
call = CGWrapper(call)
self.cgRoot.append(call)
@ -6245,7 +6261,7 @@ class CGPerSignatureCall(CGThing):
def __init__(self, returnType, arguments, nativeMethodName, static,
descriptor, idlNode, argConversionStartsAt=0, getter=False,
setter=False, isConstructor=False):
setter=False, isConstructor=False, resultVar=None):
assert idlNode.isMethod() == (not getter and not setter)
assert idlNode.isAttr() == (getter or setter)
# Constructors are always static
@ -6367,12 +6383,14 @@ class CGPerSignatureCall(CGThing):
# XXXkhuey we should be able to MOZ_ASSERT that ${obj} is
# not null.
xraySteps.append(
CGGeneric(string.Template(dedent("""
CGGeneric(fill(
"""
${obj} = js::CheckedUnwrap(${obj});
if (!${obj}) {
return false;
}
""")).substitute({'obj': unwrappedVar})))
""",
obj=unwrappedVar)))
if isConstructor:
# If we're called via an xray, we need to enter the underlying
# object's compartment and then wrap up all of our arguments into
@ -6397,7 +6415,7 @@ class CGPerSignatureCall(CGThing):
self.getErrorReport() if self.isFallible() else None,
self.getArguments(), argsPre, returnType,
self.extendedAttributes, descriptor, nativeMethodName,
static, argsPost=argsPost))
static, argsPost=argsPost, resultVar=resultVar))
self.cgRoot = CGList(cgThings)
def getArguments(self):
@ -6994,7 +7012,8 @@ class CGSetterCall(CGPerSignatureCall):
setter.
"""
def __init__(self, argType, nativeMethodName, descriptor, attr):
CGPerSignatureCall.__init__(self, None, [FakeArgument(argType, attr, allowTreatNonCallableAsNull=True)],
CGPerSignatureCall.__init__(self, None,
[FakeArgument(argType, attr, allowTreatNonCallableAsNull=True)],
nativeMethodName, attr.isStatic(),
descriptor, attr, setter=True)
@ -9395,9 +9414,19 @@ class CGProxySpecialOperation(CGPerSignatureCall):
If checkFound is False, will just assert that the prop is found instead of
checking that it is before wrapping the value.
resultVar: See the docstring for CGCallGenerator.
foundVar: For getters and deleters, the generated code can also set a bool
variable, declared by the caller, to indicate whether the given indexed or
named property already existed or not. If the caller wants this, it should
pass the name of the bool variable as the foundVar keyword argument to the
constructor. The caller is responsible for declaring the variable.
"""
def __init__(self, descriptor, operation, checkFound=True, argumentMutableValue=None):
def __init__(self, descriptor, operation, checkFound=True,
argumentMutableValue=None, resultVar=None, foundVar=None):
self.checkFound = checkFound
self.foundVar = foundVar or "found"
nativeName = MakeNativeName(descriptor.binaryNameFor(operation))
operation = descriptor.operations[operation]
@ -9410,7 +9439,7 @@ class CGProxySpecialOperation(CGPerSignatureCall):
# CGPerSignatureCall won't do any argument conversion of its own.
CGPerSignatureCall.__init__(self, returnType, arguments, nativeName,
False, descriptor, operation,
len(arguments))
len(arguments), resultVar=resultVar)
if operation.isSetter() or operation.isCreator():
# arguments[0] is the index or name of the item that we're setting.
@ -9430,14 +9459,15 @@ class CGProxySpecialOperation(CGPerSignatureCall):
}
self.cgRoot.prepend(instantiateJSToNativeConversion(info, templateValues))
elif operation.isGetter() or operation.isDeleter():
self.cgRoot.prepend(CGGeneric("bool found;\n"))
if foundVar is None:
self.cgRoot.prepend(CGGeneric("bool found;\n"))
def getArguments(self):
args = [(a, a.identifier.name) for a in self.arguments]
if self.idlNode.isGetter() or self.idlNode.isDeleter():
args.append((FakeArgument(BuiltinTypes[IDLBuiltinType.Types.boolean],
self.idlNode),
"found"))
self.foundVar))
return args
def wrap_return_value(self):
@ -9446,9 +9476,9 @@ class CGProxySpecialOperation(CGPerSignatureCall):
wrap = CGGeneric(wrapForType(self.returnType, self.descriptor, self.templateValues))
if self.checkFound:
wrap = CGIfWrapper(wrap, "found")
wrap = CGIfWrapper(wrap, self.foundVar)
else:
wrap = CGList([CGGeneric("MOZ_ASSERT(found);\n"), wrap])
wrap = CGList([CGGeneric("MOZ_ASSERT(" + self.foundVar + ");\n"), wrap])
return "\n" + wrap.define()
@ -9462,12 +9492,18 @@ class CGProxyIndexedOperation(CGProxySpecialOperation):
If checkFound is False, will just assert that the prop is found instead of
checking that it is before wrapping the value.
resultVar: See the docstring for CGCallGenerator.
foundVar: See the docstring for CGProxySpecialOperation.
"""
def __init__(self, descriptor, name, doUnwrap=True, checkFound=True,
argumentMutableValue=None):
argumentMutableValue=None, resultVar=None, foundVar=None):
self.doUnwrap = doUnwrap
CGProxySpecialOperation.__init__(self, descriptor, name, checkFound,
argumentMutableValue=argumentMutableValue)
argumentMutableValue=argumentMutableValue,
resultVar=resultVar,
foundVar=foundVar)
def define(self):
# Our first argument is the id we're getting.
@ -9496,12 +9532,14 @@ class CGProxyIndexedGetter(CGProxyIndexedOperation):
If checkFound is False, will just assert that the prop is found instead of
checking that it is before wrapping the value.
foundVar: See the docstring for CGProxySpecialOperation.
"""
def __init__(self, descriptor, templateValues=None, doUnwrap=True,
checkFound=True):
checkFound=True, foundVar=None):
self.templateValues = templateValues
CGProxyIndexedOperation.__init__(self, descriptor, 'IndexedGetter',
doUnwrap, checkFound)
doUnwrap, checkFound, foundVar=foundVar)
class CGProxyIndexedPresenceChecker(CGProxyIndexedGetter):
@ -9509,9 +9547,11 @@ class CGProxyIndexedPresenceChecker(CGProxyIndexedGetter):
Class to generate a call that checks whether an indexed property exists.
For now, we just delegate to CGProxyIndexedGetter
foundVar: See the docstring for CGProxySpecialOperation.
"""
def __init__(self, descriptor):
CGProxyIndexedGetter.__init__(self, descriptor)
def __init__(self, descriptor, foundVar):
CGProxyIndexedGetter.__init__(self, descriptor, foundVar=foundVar)
self.cgRoot.append(CGGeneric("(void)result;\n"))
@ -9527,9 +9567,15 @@ class CGProxyIndexedSetter(CGProxyIndexedOperation):
class CGProxyIndexedDeleter(CGProxyIndexedOperation):
"""
Class to generate a call to an indexed deleter.
resultVar: See the docstring for CGCallGenerator.
foundVar: See the docstring for CGProxySpecialOperation.
"""
def __init__(self, descriptor):
CGProxyIndexedOperation.__init__(self, descriptor, 'IndexedDeleter')
def __init__(self, descriptor, resultVar=None, foundVar=None):
CGProxyIndexedOperation.__init__(self, descriptor, 'IndexedDeleter',
resultVar=resultVar,
foundVar=foundVar)
class CGProxyNamedOperation(CGProxySpecialOperation):
@ -9538,10 +9584,17 @@ class CGProxyNamedOperation(CGProxySpecialOperation):
'value' is the jsval to use for the name; None indicates that it should be
gotten from the property id.
resultVar: See the docstring for CGCallGenerator.
foundVar: See the docstring for CGProxySpecialOperation.
"""
def __init__(self, descriptor, name, value=None, argumentMutableValue=None):
def __init__(self, descriptor, name, value=None, argumentMutableValue=None,
resultVar=None, foundVar=None):
CGProxySpecialOperation.__init__(self, descriptor, name,
argumentMutableValue=argumentMutableValue)
argumentMutableValue=argumentMutableValue,
resultVar=resultVar,
foundVar=foundVar)
self.value = value
def define(self):
@ -9549,38 +9602,38 @@ class CGProxyNamedOperation(CGProxySpecialOperation):
argName = self.arguments[0].identifier.name
if argName == "id":
# deal with the name collision
idDecl = "JS::Rooted<jsid> id_(cx, id);\n"
decls = "JS::Rooted<jsid> id_(cx, id);\n"
idName = "id_"
else:
idDecl = ""
decls = ""
idName = "id"
unwrapString = fill(
decls += "binding_detail::FakeString %s;\n" % argName
main = fill(
"""
if (!ConvertJSValueToString(cx, nameVal, eStringify, eStringify,
${argName})) {
return false;
}
${nativeType}* self = UnwrapProxy(proxy);
$*{op}
""",
argName=argName)
nativeType=self.descriptor.nativeType,
op=CGProxySpecialOperation.define(self))
if self.value is None:
# We're just using 'id', and if it's an atom we can take a
# fast path here.
unwrapString = fill(
return fill(
"""
if (MOZ_LIKELY(JSID_IS_STRING(${idName}))) {
if (!AssignJSString(cx, ${argName}, JSID_TO_STRING(${idName}))) {
return false;
}
} else {
nameVal = js::IdToValue(${idName});
$*{unwrapString}
$*{decls}
bool isSymbol;
if (!ConvertIdToString(cx, ${idName}, ${argName}, isSymbol)) {
return false;
}
if (!isSymbol) {
$*{main}
}
""",
decls=decls,
idName=idName,
argName=argName,
unwrapString=unwrapString)
else:
unwrapString = ("nameVal = %s;\n" % self.value) + unwrapString
main=main)
# Sadly, we have to set up nameVal even if we have an atom id,
# because we don't know for sure, and we can end up needing it
@ -9588,19 +9641,20 @@ class CGProxyNamedOperation(CGProxySpecialOperation):
# seems like probable overkill.
return fill(
"""
JS::Rooted<JS::Value> nameVal(cx);
$*{idDecl}
binding_detail::FakeString ${argName};
$*{unwrapString}
${nativeType}* self = UnwrapProxy(proxy);
$*{op}
$*{decls}
JS::Rooted<JS::Value> nameVal(cx, ${value});
if (!nameVal.isSymbol()) {
if (!ConvertJSValueToString(cx, nameVal, eStringify, eStringify,
${argName})) {
return false;
}
$*{main}
}
""",
idDecl=idDecl,
decls=decls,
value=self.value,
argName=argName,
unwrapString=unwrapString,
nativeType=self.descriptor.nativeType,
op=CGProxySpecialOperation.define(self))
main=main)
class CGProxyNamedGetter(CGProxyNamedOperation):
@ -9609,10 +9663,14 @@ class CGProxyNamedGetter(CGProxyNamedOperation):
the returned value will be wrapped with wrapForType using templateValues.
'value' is the jsval to use for the name; None indicates that it should be
gotten from the property id.
foundVar: See the docstring for CGProxySpecialOperation.
"""
def __init__(self, descriptor, templateValues=None, value=None):
def __init__(self, descriptor, templateValues=None, value=None,
foundVar=None):
self.templateValues = templateValues
CGProxyNamedOperation.__init__(self, descriptor, 'NamedGetter', value)
CGProxyNamedOperation.__init__(self, descriptor, 'NamedGetter', value,
foundVar=foundVar)
class CGProxyNamedPresenceChecker(CGProxyNamedGetter):
@ -9620,9 +9678,11 @@ class CGProxyNamedPresenceChecker(CGProxyNamedGetter):
Class to generate a call that checks whether a named property exists.
For now, we just delegate to CGProxyNamedGetter
foundVar: See the docstring for CGProxySpecialOperation.
"""
def __init__(self, descriptor):
CGProxyNamedGetter.__init__(self, descriptor)
def __init__(self, descriptor, foundVar=None):
CGProxyNamedGetter.__init__(self, descriptor, foundVar=foundVar)
self.cgRoot.append(CGGeneric("(void)result;\n"))
@ -9638,9 +9698,15 @@ class CGProxyNamedSetter(CGProxyNamedOperation):
class CGProxyNamedDeleter(CGProxyNamedOperation):
"""
Class to generate a call to a named deleter.
resultVar: See the docstring for CGCallGenerator.
foundVar: See the docstring for CGProxySpecialOperation.
"""
def __init__(self, descriptor):
CGProxyNamedOperation.__init__(self, descriptor, 'NamedDeleter')
def __init__(self, descriptor, resultVar=None, foundVar=None):
CGProxyNamedOperation.__init__(self, descriptor, 'NamedDeleter',
resultVar=resultVar,
foundVar=foundVar)
class CGProxyIsProxy(CGAbstractMethod):
@ -9871,13 +9937,14 @@ class CGDOMJSProxyHandler_defineProperty(ClassMethod):
if self.descriptor.supportsNamedProperties():
set += fill(
"""
bool found;
$*{presenceChecker}
if (found) {
return js::IsInNonStrictPropertySet(cx) || ThrowErrorMessage(cx, MSG_NO_NAMED_SETTER, "${name}");
}
""",
presenceChecker=CGProxyNamedPresenceChecker(self.descriptor).define(),
presenceChecker=CGProxyNamedPresenceChecker(self.descriptor, foundVar="found").define(),
name=self.descriptor.name)
set += ("return mozilla::dom::DOMProxyHandler::defineProperty(%s);\n" %
", ".join(a.name for a in self.args))
@ -9895,36 +9962,51 @@ class CGDOMJSProxyHandler_delete(ClassMethod):
self.descriptor = descriptor
def getBody(self):
def getDeleterBody(type):
def getDeleterBody(type, foundVar=None):
"""
type should be "Named" or "Indexed"
"""
assert type in ("Named", "Indexed")
deleter = self.descriptor.operations[type + 'Deleter']
if deleter:
decls = ""
if (not deleter.signatures()[0][0].isPrimitive() or
deleter.signatures()[0][0].nullable() or
deleter.signatures()[0][0].tag() != IDLType.Tags.bool):
setBp = "*bp = true;\n"
else:
setBp = dedent("""
if (found) {
decls += "bool result;\n"
if foundVar is None:
foundVar = "found"
decls += "bool found;\n"
setBp = fill(
"""
if (${foundVar}) {
*bp = result;
} else {
*bp = true;
}
""")
body = (eval("CGProxy%sDeleter" % type)(self.descriptor).define() +
""",
foundVar=foundVar)
deleterClass = globals()["CGProxy%sDeleter" % type]
body = (decls +
deleterClass(self.descriptor, resultVar="result", foundVar=foundVar).define() +
setBp)
elif eval("self.descriptor.supports%sProperties()" % type):
body = (eval("CGProxy%sPresenceChecker" % type)(self.descriptor).define() +
dedent("""
if (found) {
*bp = false;
} else {
*bp = true;
}
"""))
elif getattr(self.descriptor, "supports%sProperties" % type)():
presenceCheckerClass = globals()["CGProxy%sPresenceChecker" % type]
foundDecl = ""
if foundVar is None:
foundVar = "found"
foundDecl = "bool found;\n"
body = fill(
"""
$*{foundDecl}
$*{presenceChecker}
*bp = !${foundVar};
""",
foundDecl=foundDecl,
presenceChecker=presenceCheckerClass(self.descriptor, foundVar=foundVar).define(),
foundVar=foundVar)
else:
body = None
return body
@ -9962,15 +10044,20 @@ class CGDOMJSProxyHandler_delete(ClassMethod):
delete += CallOnUnforgeableHolder(self.descriptor, unforgeable)
delete += "\n"
namedBody = getDeleterBody("Named")
namedBody = getDeleterBody("Named", foundVar="found")
if namedBody is not None:
# We always return above for an index id in the case when we support
# indexed properties, so we can just treat the id as a name
# unconditionally here.
delete += (namedBody +
"if (found) {\n"
" return true;\n"
"}\n")
delete += fill(
"""
bool found;
$*{namedBody}
if (found) {
return true;
}
""",
namedBody=namedBody)
if not self.descriptor.interface.getExtendedAttribute('OverrideBuiltins'):
delete = CGIfWrapper(CGGeneric(delete),
"!HasPropertyOnPrototype(cx, proxy, id)").define()
@ -10075,6 +10162,7 @@ class CGDOMJSProxyHandler_hasOwn(ClassMethod):
"""
int32_t index = GetArrayIndexFromId(cx, id);
if (IsArrayIndex(index)) {
bool found;
$*{presenceChecker}
*bp = found;
@ -10082,7 +10170,7 @@ class CGDOMJSProxyHandler_hasOwn(ClassMethod):
}
""",
presenceChecker=CGProxyIndexedPresenceChecker(self.descriptor).define())
presenceChecker=CGProxyIndexedPresenceChecker(self.descriptor, foundVar="found").define())
else:
indexed = ""
@ -10102,9 +10190,14 @@ class CGDOMJSProxyHandler_hasOwn(ClassMethod):
if self.descriptor.supportsNamedProperties():
# If we support indexed properties we always return above for index
# property names, so no need to check for those here.
named = (CGProxyNamedPresenceChecker(self.descriptor).define() +
"\n" +
"*bp = found;\n")
named = fill(
"""
bool found;
$*{presenceChecker}
*bp = found;
""",
presenceChecker=CGProxyNamedPresenceChecker(self.descriptor, foundVar="found").define())
if not self.descriptor.interface.getExtendedAttribute('OverrideBuiltins'):
named = CGIfWrapper(CGGeneric(named + "return true;\n"),
"!HasPropertyOnPrototype(cx, proxy, id)").define()

View File

@ -82,6 +82,11 @@ function eventHandler(e) {
}
if (nbEvents == 0) {
//removeEventListener, otherwise a key event is fired
//for some reason, with keyCode 95
removeEventListener('keydown', eventHandler);
removeEventListener('keypress', eventHandler);
removeEventListener('keyup', eventHandler);
SimpleTest.finish();
return;
}

View File

@ -28,6 +28,8 @@ function runTest() {
var numMsgReceived = 0;
function outerIframeLoaded() {
// If you're changing the amount of is() calls in injectedScript,
// also change the number in waitForMessages accordingly
var injectedScript =
"data:,function is(a, b, desc) { \
if (a == b) { \
@ -63,7 +65,8 @@ function outerIframeLoaded() {
mm.loadFrameScript(injectedScript, /* allowDelayedLoad = */ false);
waitForMessages(6);
// 8 is the number of is() calls in injectedScript
waitForMessages(8);
}
function waitForMessages(num) {

View File

@ -160,12 +160,7 @@ IsTexImageCubemapTarget(GLenum target)
bool
WebGLProgram::UpdateInfo()
{
mIdentifierMap = nullptr;
mIdentifierReverseMap = nullptr;
mUniformInfoMap = nullptr;
mAttribMaxNameLength = 0;
for (size_t i = 0; i < mAttachedShaders.Length(); i++)
mAttribMaxNameLength = std::max(mAttribMaxNameLength, mAttachedShaders[i]->mAttribMaxNameLength);
@ -199,14 +194,28 @@ WebGLProgram::UpdateInfo()
}
}
if (!mUniformInfoMap) {
mUniformInfoMap = new CStringToUniformInfoMap;
for (size_t i = 0; i < mAttachedShaders.Length(); i++) {
for (size_t j = 0; j < mAttachedShaders[i]->mUniforms.Length(); j++) {
const WebGLMappedIdentifier& uniform = mAttachedShaders[i]->mUniforms[j];
const WebGLUniformInfo& info = mAttachedShaders[i]->mUniformInfos[j];
mUniformInfoMap->Put(uniform.mapped, info);
}
// nsAutoPtr will delete old version first
mIdentifierMap = new CStringMap;
mIdentifierReverseMap = new CStringMap;
mUniformInfoMap = new CStringToUniformInfoMap;
for (size_t i = 0; i < mAttachedShaders.Length(); i++) {
// Loop through ATTRIBUTES
for (size_t j = 0; j < mAttachedShaders[i]->mAttributes.Length(); j++) {
const WebGLMappedIdentifier& attrib = mAttachedShaders[i]->mAttributes[j];
mIdentifierMap->Put(attrib.original, attrib.mapped); // FORWARD MAPPING
mIdentifierReverseMap->Put(attrib.mapped, attrib.original); // REVERSE MAPPING
}
// Loop through UNIFORMS
for (size_t j = 0; j < mAttachedShaders[i]->mUniforms.Length(); j++) {
// Add the uniforms name mapping to mIdentifier[Reverse]Map
const WebGLMappedIdentifier& uniform = mAttachedShaders[i]->mUniforms[j];
mIdentifierMap->Put(uniform.original, uniform.mapped); // FOWARD MAPPING
mIdentifierReverseMap->Put(uniform.mapped, uniform.original); // REVERSE MAPPING
// Add uniform info to mUniformInfoMap
const WebGLUniformInfo& info = mAttachedShaders[i]->mUniformInfos[j];
mUniformInfoMap->Put(uniform.mapped, info);
}
}

View File

@ -55,6 +55,9 @@ WebGLProgram::WebGLProgram(WebGLContext *context)
: WebGLContextBoundObject(context)
, mLinkStatus(false)
, mGeneration(0)
, mIdentifierMap(new CStringMap)
, mIdentifierReverseMap(new CStringMap)
, mUniformInfoMap(new CStringToUniformInfoMap)
, mAttribMaxNameLength(0)
{
SetIsDOMBinding();
@ -135,20 +138,7 @@ WebGLProgram::UpperBoundNumSamplerUniforms() {
void
WebGLProgram::MapIdentifier(const nsACString& name, nsCString *mappedName) {
if (!mIdentifierMap) {
// if the identifier map doesn't exist yet, build it now
mIdentifierMap = new CStringMap;
for (size_t i = 0; i < mAttachedShaders.Length(); i++) {
for (size_t j = 0; j < mAttachedShaders[i]->mAttributes.Length(); j++) {
const WebGLMappedIdentifier& attrib = mAttachedShaders[i]->mAttributes[j];
mIdentifierMap->Put(attrib.original, attrib.mapped);
}
for (size_t j = 0; j < mAttachedShaders[i]->mUniforms.Length(); j++) {
const WebGLMappedIdentifier& uniform = mAttachedShaders[i]->mUniforms[j];
mIdentifierMap->Put(uniform.original, uniform.mapped);
}
}
}
MOZ_ASSERT(mIdentifierMap);
nsCString mutableName(name);
nsCString bracketPart;
@ -180,20 +170,7 @@ WebGLProgram::MapIdentifier(const nsACString& name, nsCString *mappedName) {
void
WebGLProgram::ReverseMapIdentifier(const nsACString& name, nsCString *reverseMappedName) {
if (!mIdentifierReverseMap) {
// if the identifier reverse map doesn't exist yet, build it now
mIdentifierReverseMap = new CStringMap;
for (size_t i = 0; i < mAttachedShaders.Length(); i++) {
for (size_t j = 0; j < mAttachedShaders[i]->mAttributes.Length(); j++) {
const WebGLMappedIdentifier& attrib = mAttachedShaders[i]->mAttributes[j];
mIdentifierReverseMap->Put(attrib.mapped, attrib.original);
}
for (size_t j = 0; j < mAttachedShaders[i]->mUniforms.Length(); j++) {
const WebGLMappedIdentifier& uniform = mAttachedShaders[i]->mUniforms[j];
mIdentifierReverseMap->Put(uniform.mapped, uniform.original);
}
}
}
MOZ_ASSERT(mIdentifierReverseMap);
nsCString mutableName(name);
nsCString bracketPart;
@ -225,6 +202,8 @@ WebGLProgram::ReverseMapIdentifier(const nsACString& name, nsCString *reverseMap
WebGLUniformInfo
WebGLProgram::GetUniformInfoForMappedIdentifier(const nsACString& name) {
MOZ_ASSERT(mUniformInfoMap);
nsCString mutableName(name);
nsCString bracketPart;
bool hadBracketPart = SplitLastSquareBracket(mutableName, bracketPart);

View File

@ -25,6 +25,7 @@ EXPORTS.mozilla.dom += [
'TextMetrics.h',
]
# Canvas 2D and common sources
UNIFIED_SOURCES += [
'CanvasImageCache.cpp',
'CanvasRenderingContext2D.cpp',
@ -35,76 +36,72 @@ UNIFIED_SOURCES += [
'ImageEncoder.cpp',
]
if CONFIG['MOZ_WEBGL']:
UNIFIED_SOURCES += [
'MurmurHash3.cpp',
'WebGL1Context.cpp',
'WebGL2Context.cpp',
'WebGLActiveInfo.cpp',
'WebGLBindableName.cpp',
'WebGLBuffer.cpp',
'WebGLContext.cpp',
'WebGLContextAsyncQueries.cpp',
'WebGLContextBuffers.cpp',
'WebGLContextDraw.cpp',
'WebGLContextExtensions.cpp',
'WebGLContextFramebufferOperations.cpp',
'WebGLContextGL.cpp',
'WebGLContextLossTimer.cpp',
'WebGLContextReporter.cpp',
'WebGLContextState.cpp',
'WebGLContextUtils.cpp',
'WebGLContextValidate.cpp',
'WebGLContextVertexArray.cpp',
'WebGLContextVertices.cpp',
'WebGLElementArrayCache.cpp',
'WebGLExtensionBase.cpp',
'WebGLExtensionBlendMinMax.cpp',
'WebGLExtensionColorBufferFloat.cpp',
'WebGLExtensionColorBufferHalfFloat.cpp',
'WebGLExtensionCompressedTextureATC.cpp',
'WebGLExtensionCompressedTextureETC1.cpp',
'WebGLExtensionCompressedTexturePVRTC.cpp',
'WebGLExtensionCompressedTextureS3TC.cpp',
'WebGLExtensionDebugRendererInfo.cpp',
'WebGLExtensionDebugShaders.cpp',
'WebGLExtensionDepthTexture.cpp',
'WebGLExtensionDrawBuffers.cpp',
'WebGLExtensionElementIndexUint.cpp',
'WebGLExtensionFragDepth.cpp',
'WebGLExtensionInstancedArrays.cpp',
'WebGLExtensionLoseContext.cpp',
'WebGLExtensionShaderTextureLod.cpp',
'WebGLExtensionSRGB.cpp',
'WebGLExtensionStandardDerivatives.cpp',
'WebGLExtensionTextureFilterAnisotropic.cpp',
'WebGLExtensionTextureFloat.cpp',
'WebGLExtensionTextureFloatLinear.cpp',
'WebGLExtensionTextureHalfFloat.cpp',
'WebGLExtensionTextureHalfFloatLinear.cpp',
'WebGLExtensionVertexArray.cpp',
'WebGLFramebuffer.cpp',
'WebGLFramebufferAttachable.cpp',
'WebGLObjectModel.cpp',
'WebGLProgram.cpp',
'WebGLQuery.cpp',
'WebGLRenderbuffer.cpp',
'WebGLShader.cpp',
'WebGLShaderPrecisionFormat.cpp',
'WebGLTexelConversions.cpp',
'WebGLTexture.cpp',
'WebGLUniformLocation.cpp',
'WebGLVertexArray.cpp',
'WebGLVertexArrayFake.cpp',
'WebGLVertexArrayGL.cpp',
]
LOCAL_INCLUDES += [
'/js/xpconnect/wrappers',
]
else:
UNIFIED_SOURCES += [
'WebGLContextNotSupported.cpp',
]
# WebGL Sources
UNIFIED_SOURCES += [
'MurmurHash3.cpp',
'WebGL1Context.cpp',
'WebGL2Context.cpp',
'WebGLActiveInfo.cpp',
'WebGLBindableName.cpp',
'WebGLBuffer.cpp',
'WebGLContext.cpp',
'WebGLContextAsyncQueries.cpp',
'WebGLContextBuffers.cpp',
'WebGLContextDraw.cpp',
'WebGLContextExtensions.cpp',
'WebGLContextFramebufferOperations.cpp',
'WebGLContextGL.cpp',
'WebGLContextLossTimer.cpp',
'WebGLContextReporter.cpp',
'WebGLContextState.cpp',
'WebGLContextUtils.cpp',
'WebGLContextValidate.cpp',
'WebGLContextVertexArray.cpp',
'WebGLContextVertices.cpp',
'WebGLElementArrayCache.cpp',
'WebGLExtensionBase.cpp',
'WebGLExtensionBlendMinMax.cpp',
'WebGLExtensionColorBufferFloat.cpp',
'WebGLExtensionColorBufferHalfFloat.cpp',
'WebGLExtensionCompressedTextureATC.cpp',
'WebGLExtensionCompressedTextureETC1.cpp',
'WebGLExtensionCompressedTexturePVRTC.cpp',
'WebGLExtensionCompressedTextureS3TC.cpp',
'WebGLExtensionDebugRendererInfo.cpp',
'WebGLExtensionDebugShaders.cpp',
'WebGLExtensionDepthTexture.cpp',
'WebGLExtensionDrawBuffers.cpp',
'WebGLExtensionElementIndexUint.cpp',
'WebGLExtensionFragDepth.cpp',
'WebGLExtensionInstancedArrays.cpp',
'WebGLExtensionLoseContext.cpp',
'WebGLExtensionShaderTextureLod.cpp',
'WebGLExtensionSRGB.cpp',
'WebGLExtensionStandardDerivatives.cpp',
'WebGLExtensionTextureFilterAnisotropic.cpp',
'WebGLExtensionTextureFloat.cpp',
'WebGLExtensionTextureFloatLinear.cpp',
'WebGLExtensionTextureHalfFloat.cpp',
'WebGLExtensionTextureHalfFloatLinear.cpp',
'WebGLExtensionVertexArray.cpp',
'WebGLFramebuffer.cpp',
'WebGLFramebufferAttachable.cpp',
'WebGLObjectModel.cpp',
'WebGLProgram.cpp',
'WebGLQuery.cpp',
'WebGLRenderbuffer.cpp',
'WebGLShader.cpp',
'WebGLShaderPrecisionFormat.cpp',
'WebGLTexelConversions.cpp',
'WebGLTexture.cpp',
'WebGLUniformLocation.cpp',
'WebGLVertexArray.cpp',
'WebGLVertexArrayFake.cpp',
'WebGLVertexArrayGL.cpp',
]
LOCAL_INCLUDES += [
'/js/xpconnect/wrappers',
]
FAIL_ON_WARNINGS = True

View File

@ -23,33 +23,12 @@ XPCOMUtils.defineLazyServiceGetter(this, "dataStoreService",
"@mozilla.org/datastore-service;1",
"nsIDataStoreService");
XPCOMUtils.defineLazyServiceGetter(this, "systemMessenger",
"@mozilla.org/system-message-internal;1",
"nsISystemMessagesInternal");
var kSysMsgOnChangeShortTimeoutSec =
Services.prefs.getIntPref("dom.datastore.sysMsgOnChangeShortTimeoutSec");
var kSysMsgOnChangeLongTimeoutSec =
Services.prefs.getIntPref("dom.datastore.sysMsgOnChangeLongTimeoutSec");
this.DataStoreChangeNotifier = {
children: [],
messages: [ "DataStore:Changed", "DataStore:RegisterForMessages",
"DataStore:UnregisterForMessages",
"child-process-shutdown" ],
// These hashes are used for storing the mapping between the datastore
// identifiers (name | owner manifest URL) and their correspondent timers.
// The object literal is defined as below:
//
// {
// "datastore name 1|owner manifest URL 1": timer1,
// "datastore name 2|owner manifest URL 2": timer2,
// ...
// }
sysMsgOnChangeShortTimers: {},
sysMsgOnChangeLongTimers: {},
init: function() {
debug("init");
@ -80,8 +59,7 @@ this.DataStoreChangeNotifier = {
},
broadcastMessage: function broadcastMessage(aData) {
debug("broadcast");
debug("Broadast");
this.children.forEach(function(obj) {
if (obj.store == aData.store && obj.owner == aData.owner) {
obj.mm.sendAsyncMessage("DataStore:Changed:Return:OK", aData);
@ -89,69 +67,6 @@ this.DataStoreChangeNotifier = {
});
},
broadcastSystemMessage: function(aStore, aOwner) {
debug("broadcastSystemMessage");
// Clear relevant timers.
var storeKey = aStore + "|" + aOwner;
var shortTimer = this.sysMsgOnChangeShortTimers[storeKey];
if (shortTimer) {
shortTimer.cancel();
delete this.sysMsgOnChangeShortTimers[storeKey];
}
var longTimer = this.sysMsgOnChangeLongTimers[storeKey];
if (longTimer) {
longTimer.cancel();
delete this.sysMsgOnChangeLongTimers[storeKey];
}
// Get all the manifest URLs of the apps which can access the datastore.
var manifestURLs = dataStoreService.getAppManifestURLsForDataStore(aStore);
var enumerate = manifestURLs.enumerate();
while (enumerate.hasMoreElements()) {
var manifestURL = enumerate.getNext().QueryInterface(Ci.nsISupportsString);
debug("Notify app " + manifestURL + " of datastore updates");
// Send the system message 'datastore-update-{store name}' to all the
// pages for these apps. With the manifest URL of the owner in the message
// payload, it notifies the consumer a sync operation should be performed.
systemMessenger.sendMessage("datastore-update-" + aStore,
{ owner: aOwner },
null,
Services.io.newURI(manifestURL, null, null));
}
},
// Use the following logic to broadcast system messages in a moderate pattern.
// 1. When an entry is changed, start a short timer and a long timer.
// 2. If an entry is changed while the short timer is running, reset it.
// Do not reset the long timer.
// 3. Once either fires, broadcast the system message and cancel both timers.
setSystemMessageTimeout: function(aStore, aOwner) {
debug("setSystemMessageTimeout");
var storeKey = aStore + "|" + aOwner;
// Reset the short timer.
var shortTimer = this.sysMsgOnChangeShortTimers[storeKey];
if (!shortTimer) {
shortTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
this.sysMsgOnChangeShortTimers[storeKey] = shortTimer;
} else {
shortTimer.cancel();
}
shortTimer.initWithCallback({ notify: this.broadcastSystemMessage.bind(this, aStore, aOwner) },
kSysMsgOnChangeShortTimeoutSec * 1000,
Ci.nsITimer.TYPE_ONE_SHOT);
// Set the long timer if necessary.
if (!this.sysMsgOnChangeLongTimers[storeKey]) {
var longTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
this.sysMsgOnChangeLongTimers[storeKey] = longTimer;
longTimer.initWithCallback({ notify: this.broadcastSystemMessage.bind(this, aStore, aOwner) },
kSysMsgOnChangeLongTimeoutSec * 1000,
Ci.nsITimer.TYPE_ONE_SHOT);
}
},
receiveMessage: function(aMessage) {
debug("receiveMessage ");
@ -174,9 +89,6 @@ this.DataStoreChangeNotifier = {
switch (aMessage.name) {
case "DataStore:Changed":
this.broadcastMessage(aMessage.data);
if (Services.prefs.getBoolPref("dom.sysmsg.enabled")) {
this.setSystemMessageTimeout(aMessage.data.store, aMessage.data.owner);
}
break;
case "DataStore:RegisterForMessages":

View File

@ -33,11 +33,9 @@
#include "nsIDocument.h"
#include "nsIDOMGlobalPropertyInitializer.h"
#include "nsIIOService.h"
#include "nsIMutableArray.h"
#include "nsIObserverService.h"
#include "nsIPermissionManager.h"
#include "nsIScriptSecurityManager.h"
#include "nsISupportsPrimitives.h"
#include "nsIUUIDGenerator.h"
#include "nsPIDOMWindow.h"
#include "nsIURI.h"
@ -377,24 +375,6 @@ GetDataStoreInfosEnumerator(const uint32_t& aAppId,
return PL_DHASH_NEXT;
}
PLDHashOperator
GetAppManifestURLsEnumerator(const uint32_t& aAppId,
DataStoreInfo* aInfo,
void* aUserData)
{
AssertIsInMainProcess();
MOZ_ASSERT(NS_IsMainThread());
auto* manifestURLs = static_cast<nsIMutableArray*>(aUserData);
nsCOMPtr<nsISupportsString> manifestURL(do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID));
if (manifestURL) {
manifestURL->SetData(aInfo->mManifestURL);
manifestURLs->AppendElement(manifestURL, false);
}
return PL_DHASH_NEXT;
}
// This class is useful to enumerate the add permissions for each app.
class MOZ_STACK_CLASS AddPermissionsData
{
@ -1077,31 +1057,6 @@ DataStoreService::GetDataStoreInfos(const nsAString& aName,
return NS_OK;
}
NS_IMETHODIMP
DataStoreService::GetAppManifestURLsForDataStore(const nsAString& aName,
nsIArray** aManifestURLs)
{
ASSERT_PARENT_PROCESS()
MOZ_ASSERT(NS_IsMainThread());
nsCOMPtr<nsIMutableArray> manifestURLs = do_CreateInstance(NS_ARRAY_CONTRACTID);
if (!manifestURLs) {
return NS_ERROR_OUT_OF_MEMORY;
}
HashApp* apps = nullptr;
if (mStores.Get(aName, &apps)) {
apps->EnumerateRead(GetAppManifestURLsEnumerator, manifestURLs.get());
}
if (mAccessStores.Get(aName, &apps)) {
apps->EnumerateRead(GetAppManifestURLsEnumerator, manifestURLs.get());
}
*aManifestURLs = manifestURLs;
NS_ADDREF(*aManifestURLs);
return NS_OK;
}
bool
DataStoreService::CheckPermission(nsIPrincipal* aPrincipal)
{

View File

@ -7,9 +7,8 @@
interface nsIDOMWindow;
interface nsIPrincipal;
interface nsIArray;
[scriptable, uuid(79944b1c-187d-11e4-abb6-74d02b97e723)]
[scriptable, uuid(9b59c49a-0cd7-11e4-b096-74d02b97e723)]
interface nsIDataStoreService : nsISupports
{
void installDataStore(in unsigned long appId,
@ -28,7 +27,5 @@ interface nsIDataStoreService : nsISupports
in DOMString name,
in DOMString owner);
nsIArray getAppManifestURLsForDataStore(in DOMString name);
boolean checkPermission(in nsIPrincipal principal);
};

View File

@ -1,120 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Test for DataStore - notify updates with system messages</title>
</head>
<body>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript;version=1.7">
var gStore;
var gChangeId = null;
var gChangeOperation = null;
var gIsSystemMessageFired = false;
function is(a, b, msg) {
alert((a === b ? 'OK' : 'KO') + ' ' + msg)
}
function ok(a, msg) {
alert((a ? 'OK' : 'KO')+ ' ' + msg)
}
function cbError() {
alert('KO error');
}
function finish() {
alert('DONE');
}
function testGetDataStores() {
navigator.getDataStores('foo').then(function(stores) {
is(stores.length, 1, "getDataStores('foo') returns 1 element");
is(stores[0].name, 'foo', 'The dataStore.name is foo');
is(stores[0].readOnly, false, 'The dataStore foo is not in readonly');
gStore = stores[0];
runTest();
}, cbError);
}
function testStoreAdd(value, expectedId) {
gStore.add(value).then(function(id) {
is(id, expectedId, "store.add() is called");
}, cbError);
}
function eventListener(evt) {
ok(evt instanceof DataStoreChangeEvent, "DataStoreChangeEvent has been received");
ok(evt, "OnChangeListener is called with data");
is(/[0-9a-zA-Z]{8}-[0-9a-zA-Z]{4}-[0-9a-zA-Z]{4}-[0-9a-zA-Z]{4}-[0-9a-zA-Z]{12}/.test(evt.revisionId), true, "event.revisionId returns something");
is(evt.id, gChangeId, "OnChangeListener is called with the right ID: " + evt.id);
is(evt.operation, gChangeOperation, "OnChangeListener is called with the right operation:" + evt.operation + " " + gChangeOperation);
runTest();
}
function onDatastoreUpdateFoo(message) {
gIsSystemMessageFired = true;
ok(true, "System message 'datastore-update-foo' has been received");
runTest();
}
var tests = [
// Test for GetDataStore.
testGetDataStores,
// Add onchange = function.
function() {
gStore.onchange = eventListener;
is(gStore.onchange, eventListener, "onChange is set");
runTest();
},
// Set system message handler.
function() {
navigator.mozSetMessageHandler('datastore-update-foo', onDatastoreUpdateFoo);
runTest();
},
// Add.
function() { gChangeId = 1; gChangeOperation = 'added';
testStoreAdd({ number: 42 }, 1); },
// Remove event listener.
function() {
gStore.removeEventListener('change', eventListener);
runTest();
},
// Ensure the system message has fired and no more pending ones.
function() {
// Periodically check whether the system message has fired.
var timer = setInterval(function() {
if (gIsSystemMessageFired) {
clearInterval(timer);
ok(true, "The system message has fired");
ok(!navigator.mozHasPendingMessage('datastore-update-foo'), "No more pending system message");
finish();
}
}, 1000);
}
];
function runTest() {
if (tests.length) {
var test = tests.shift();
test();
}
}
runTest();
</script>
</pre>
</body>
</html>

View File

@ -30,7 +30,6 @@ support-files =
file_sync_common.js
file_bug1008044.html
file_bug957086.html
file_notify_system_message.html
[test_app_install.html]
[test_readonly.html]
@ -51,5 +50,3 @@ support-files =
[test_transactions.html]
[test_bug1008044.html]
[test_bug957086.html]
[test_notify_system_message.html]
skip-if = toolkit == 'gonk' || buildapp == 'mulet' # b2g or mulet

View File

@ -10,6 +10,10 @@
<div id="container"></div>
<script type="application/javascript;version=1.7">
if (SpecialPowers.isMainProcess()) {
SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
}
SimpleTest.waitForExplicitFinish();
var gBaseURL = 'http://test/tests/dom/datastore/tests/';
@ -22,14 +26,8 @@
{ "type": "webapps-manage", "allow": 1, "context": document }],
function() {
SpecialPowers.pushPrefEnv({"set": [["dom.datastore.enabled", true],
["dom.datastore.sysMsgOnChangeShortTimeoutSec", 1],
["dom.datastore.sysMsgOnChangeLongTimeoutSec", 3],
["dom.testing.ignore_ipc_principal", true],
["dom.testing.datastore_enabled_for_hosted_apps", true]]}, function() {
if (SpecialPowers.isMainProcess()) {
SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
}
gGenerator.next(); });
});

View File

@ -77,17 +77,11 @@
// Preferences
function() {
SpecialPowers.pushPrefEnv({"set": [["dom.datastore.enabled", true],
["dom.datastore.sysMsgOnChangeShortTimeoutSec", 1],
["dom.datastore.sysMsgOnChangeLongTimeoutSec", 3],
["dom.testing.ignore_ipc_principal", true],
["dom.testing.datastore_enabled_for_hosted_apps", true]]}, runTest);
},
function() {
if (SpecialPowers.isMainProcess()) {
SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
}
SpecialPowers.setAllAppsLaunchable(true);
SpecialPowers.setBoolPref("dom.mozBrowserFramesEnabled", true);
runTest();
@ -122,6 +116,10 @@
SimpleTest.finish();
}
if (SpecialPowers.isMainProcess()) {
SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
}
SimpleTest.waitForExplicitFinish();
runTest();
</script>

View File

@ -77,17 +77,11 @@
// Preferences
function() {
SpecialPowers.pushPrefEnv({"set": [["dom.datastore.enabled", true],
["dom.datastore.sysMsgOnChangeShortTimeoutSec", 1],
["dom.datastore.sysMsgOnChangeLongTimeoutSec", 3],
["dom.testing.ignore_ipc_principal", true],
["dom.testing.datastore_enabled_for_hosted_apps", true]]}, runTest);
},
function() {
if (SpecialPowers.isMainProcess()) {
SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
}
SpecialPowers.setAllAppsLaunchable(true);
SpecialPowers.setBoolPref("dom.mozBrowserFramesEnabled", true);
runTest();
@ -122,6 +116,10 @@
SimpleTest.finish();
}
if (SpecialPowers.isMainProcess()) {
SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
}
SimpleTest.waitForExplicitFinish();
runTest();
</script>

View File

@ -77,17 +77,11 @@
// Preferences
function() {
SpecialPowers.pushPrefEnv({"set": [["dom.datastore.enabled", true],
["dom.datastore.sysMsgOnChangeShortTimeoutSec", 1],
["dom.datastore.sysMsgOnChangeLongTimeoutSec", 3],
["dom.testing.ignore_ipc_principal", true],
["dom.testing.datastore_enabled_for_hosted_apps", true]]}, runTest);
},
function() {
if (SpecialPowers.isMainProcess()) {
SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
}
SpecialPowers.setAllAppsLaunchable(true);
SpecialPowers.setBoolPref("dom.mozBrowserFramesEnabled", true);
runTest();
@ -122,6 +116,10 @@
SimpleTest.finish();
}
if (SpecialPowers.isMainProcess()) {
SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
}
SimpleTest.waitForExplicitFinish();
runTest();
</script>

View File

@ -77,18 +77,12 @@
// Preferences
function() {
SpecialPowers.pushPrefEnv({"set": [["dom.datastore.enabled", true],
["dom.datastore.sysMsgOnChangeShortTimeoutSec", 1],
["dom.datastore.sysMsgOnChangeLongTimeoutSec", 3],
["dom.ipc.browser_frames.oop_by_default", true],
["dom.testing.ignore_ipc_principal", true],
["dom.testing.datastore_enabled_for_hosted_apps", true]]}, runTest);
},
function() {
if (SpecialPowers.isMainProcess()) {
SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
}
SpecialPowers.setAllAppsLaunchable(true);
SpecialPowers.setBoolPref("dom.mozBrowserFramesEnabled", true);
runTest();
@ -123,6 +117,10 @@
SimpleTest.finish();
}
if (SpecialPowers.isMainProcess()) {
SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
}
SimpleTest.waitForExplicitFinish();
runTest();
</script>

View File

@ -77,17 +77,11 @@
// Preferences
function() {
SpecialPowers.pushPrefEnv({"set": [["dom.datastore.enabled", true],
["dom.datastore.sysMsgOnChangeShortTimeoutSec", 1],
["dom.datastore.sysMsgOnChangeLongTimeoutSec", 3],
["dom.testing.ignore_ipc_principal", true],
["dom.testing.datastore_enabled_for_hosted_apps", true]]}, runTest);
},
function() {
if (SpecialPowers.isMainProcess()) {
SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
}
SpecialPowers.setAllAppsLaunchable(true);
SpecialPowers.setBoolPref("dom.mozBrowserFramesEnabled", true);
runTest();
@ -122,6 +116,10 @@
SimpleTest.finish();
}
if (SpecialPowers.isMainProcess()) {
SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
}
SimpleTest.waitForExplicitFinish();
runTest();
</script>

View File

@ -81,18 +81,12 @@
// Preferences
function() {
SpecialPowers.pushPrefEnv({"set": [["dom.datastore.enabled", true],
["dom.datastore.sysMsgOnChangeShortTimeoutSec", 1],
["dom.datastore.sysMsgOnChangeLongTimeoutSec", 3],
["dom.ipc.browser_frames.oop_by_default", true],
["dom.testing.ignore_ipc_principal", true],
["dom.testing.datastore_enabled_for_hosted_apps", true]]}, runTest);
},
function() {
if (SpecialPowers.isMainProcess()) {
SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
}
SpecialPowers.setAllAppsLaunchable(true);
SpecialPowers.setBoolPref("dom.mozBrowserFramesEnabled", true);
runTest();
@ -130,6 +124,10 @@
SimpleTest.finish();
}
if (SpecialPowers.isMainProcess()) {
SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
}
SimpleTest.waitForExplicitFinish();
runTest();
</script>

View File

@ -82,17 +82,11 @@
// Preferences
function() {
SpecialPowers.pushPrefEnv({"set": [["dom.datastore.enabled", true],
["dom.datastore.sysMsgOnChangeShortTimeoutSec", 1],
["dom.datastore.sysMsgOnChangeLongTimeoutSec", 3],
["dom.testing.ignore_ipc_principal", true],
["dom.testing.datastore_enabled_for_hosted_apps", true]]}, runTest);
},
function() {
if (SpecialPowers.isMainProcess()) {
SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
}
SpecialPowers.setAllAppsLaunchable(true);
SpecialPowers.setBoolPref("dom.mozBrowserFramesEnabled", true);
runTest();
@ -130,6 +124,10 @@
SimpleTest.finish();
}
if (SpecialPowers.isMainProcess()) {
SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
}
SimpleTest.waitForExplicitFinish();
runTest();
</script>

View File

@ -75,17 +75,12 @@
// Preferences
function() {
SpecialPowers.pushPrefEnv({"set": [["dom.datastore.enabled", true],
["dom.datastore.sysMsgOnChangeShortTimeoutSec", 1],
["dom.datastore.sysMsgOnChangeLongTimeoutSec", 3],
["dom.testing.ignore_ipc_principal", true],
["dom.testing.datastore_enabled_for_hosted_apps", true]]}, runTest);
},
// Enabling mozBrowser
function() {
if (SpecialPowers.isMainProcess()) {
SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
}
SpecialPowers.setAllAppsLaunchable(true);
SpecialPowers.pushPrefEnv({"set": [["dom.mozBrowserFramesEnabled", true]]}, runTest);
},
@ -139,6 +134,10 @@
SimpleTest.finish();
}
if (SpecialPowers.isMainProcess()) {
SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
}
SimpleTest.waitForExplicitFinish();
runTest();
</script>

View File

@ -77,8 +77,6 @@
// Preferences
function() {
SpecialPowers.pushPrefEnv({"set": [["dom.datastore.enabled", true],
["dom.datastore.sysMsgOnChangeShortTimeoutSec", 1],
["dom.datastore.sysMsgOnChangeLongTimeoutSec", 3],
["dom.testing.ignore_ipc_principal", true],
["dom.testing.datastore_enabled_for_hosted_apps", false]]}, runTest);
},
@ -91,10 +89,6 @@
},
function() {
if (SpecialPowers.isMainProcess()) {
SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
}
SpecialPowers.setAllAppsLaunchable(true);
SpecialPowers.setBoolPref("dom.mozBrowserFramesEnabled", true);
runTest();
@ -129,6 +123,10 @@
SimpleTest.finish();
}
if (SpecialPowers.isMainProcess()) {
SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
}
SimpleTest.waitForExplicitFinish();
runTest();
</script>

View File

@ -121,17 +121,12 @@
// Preferences
function() {
SpecialPowers.pushPrefEnv({"set": [["dom.datastore.enabled", true],
["dom.datastore.sysMsgOnChangeShortTimeoutSec", 1],
["dom.datastore.sysMsgOnChangeLongTimeoutSec", 3],
["dom.testing.ignore_ipc_principal", true],
["dom.testing.datastore_enabled_for_hosted_apps", true]]}, runTest);
},
// Enabling mozBrowser
function() {
if (SpecialPowers.isMainProcess()) {
SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
}
SpecialPowers.setAllAppsLaunchable(true);
SpecialPowers.pushPrefEnv({"set": [["dom.mozBrowserFramesEnabled", true]]}, runTest);
},
@ -174,6 +169,10 @@
SimpleTest.finish();
}
if (SpecialPowers.isMainProcess()) {
SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
}
SimpleTest.waitForExplicitFinish();
runTest();
</script>

View File

@ -77,17 +77,11 @@
// Preferences
function() {
SpecialPowers.pushPrefEnv({"set": [["dom.datastore.enabled", true],
["dom.datastore.sysMsgOnChangeShortTimeoutSec", 1],
["dom.datastore.sysMsgOnChangeLongTimeoutSec", 3],
["dom.testing.ignore_ipc_principal", true],
["dom.testing.datastore_enabled_for_hosted_apps", true]]}, runTest);
},
function() {
if (SpecialPowers.isMainProcess()) {
SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
}
SpecialPowers.setAllAppsLaunchable(true);
SpecialPowers.setBoolPref("dom.mozBrowserFramesEnabled", true);
runTest();
@ -122,6 +116,10 @@
SimpleTest.finish();
}
if (SpecialPowers.isMainProcess()) {
SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
}
SimpleTest.waitForExplicitFinish();
runTest();
</script>

View File

@ -77,17 +77,11 @@
// Preferences
function() {
SpecialPowers.pushPrefEnv({"set": [["dom.datastore.enabled", true],
["dom.datastore.sysMsgOnChangeShortTimeoutSec", 1],
["dom.datastore.sysMsgOnChangeLongTimeoutSec", 3],
["dom.testing.ignore_ipc_principal", true],
["dom.testing.datastore_enabled_for_hosted_apps", true]]}, runTest);
},
function() {
if (SpecialPowers.isMainProcess()) {
SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
}
SpecialPowers.setAllAppsLaunchable(true);
SpecialPowers.setBoolPref("dom.mozBrowserFramesEnabled", true);
runTest();
@ -122,6 +116,10 @@
SimpleTest.finish();
}
if (SpecialPowers.isMainProcess()) {
SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
}
SimpleTest.waitForExplicitFinish();
runTest();
</script>

View File

@ -1,138 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Test for DataStore - notify updates with system messages</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<div id="container"></div>
<script type="application/javascript;version=1.7">
var gHostedManifestURL = 'http://test/tests/dom/datastore/tests/file_app.sjs?testToken=file_notify_system_message.html';
var gHostedPageURL = 'http://mochi.test:8888/tests/dom/datastore/tests/file_notify_system_message.html';
var gApp;
function cbError() {
ok(false, "Error callback invoked");
finish();
}
function installApp() {
var request = navigator.mozApps.install(gHostedManifestURL);
request.onerror = cbError;
request.onsuccess = function() {
gApp = request.result;
runTest();
}
}
function uninstallApp() {
// Uninstall the app.
var request = navigator.mozApps.mgmt.uninstall(gApp);
request.onerror = cbError;
request.onsuccess = function() {
// All done.
info("All done");
runTest();
}
}
function testApp() {
var ifr = document.createElement('iframe');
ifr.setAttribute('mozbrowser', 'true');
ifr.setAttribute('mozapp', gApp.manifestURL);
ifr.setAttribute('src', gApp.manifest.launch_path);
var domParent = document.getElementById('container');
// Set us up to listen for messages from the app.
var listener = function(e) {
var message = e.detail.message;
if (/^OK/.exec(message)) {
ok(true, "Message from app: " + message);
} else if (/KO/.exec(message)) {
ok(false, "Message from app: " + message);
} else if (/DONE/.exec(message)) {
ok(true, "Messaging from app complete");
ifr.removeEventListener('mozbrowsershowmodalprompt', listener);
domParent.removeChild(ifr);
runTest();
}
}
// This event is triggered when the app calls "alert".
ifr.addEventListener('mozbrowsershowmodalprompt', listener, false);
domParent.appendChild(ifr);
}
var tests = [
// Permissions.
function() {
SpecialPowers.pushPermissions(
[{ "type": "browser", "allow": 1, "context": document },
{ "type": "embed-apps", "allow": 1, "context": document },
{ "type": "webapps-manage", "allow": 1, "context": document }], runTest);
},
// Preferences.
function() {
SpecialPowers.pushPrefEnv({"set": [["dom.datastore.enabled", true],
["dom.datastore.sysMsgOnChangeShortTimeoutSec", 1],
["dom.datastore.sysMsgOnChangeLongTimeoutSec", 3],
["dom.sysmsg.enabled", true],
["dom.testing.ignore_ipc_principal", true],
["dom.testing.datastore_enabled_for_hosted_apps", true],
["dom.mozBrowserFramesEnabled", true]]}, runTest);
},
function() {
SpecialPowers.setAllAppsLaunchable(true);
// No confirmation needed when an app is installed.
SpecialPowers.autoConfirmAppInstall(runTest);
},
function() {
if (SpecialPowers.isMainProcess()) {
SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
SpecialPowers.Cu.import("resource://gre/modules/Services.jsm");
var ioService = SpecialPowers.Cc["@mozilla.org/network/io-service;1"]
.getService(SpecialPowers.Ci.nsIIOService);
var systemMessenger = SpecialPowers.Cc["@mozilla.org/system-message-internal;1"]
.getService(SpecialPowers.Ci.nsISystemMessagesInternal);
systemMessenger.registerPage("datastore-update-foo",
ioService.newURI(gHostedPageURL, null, null),
ioService.newURI(gHostedManifestURL, null, null));
}
runTest();
},
// Installing the app.
installApp,
// Run tests in app.
testApp,
// Uninstall the app.
uninstallApp
];
function runTest() {
if (!tests.length) {
finish();
return;
}
var test = tests.shift();
test();
}
function finish() {
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
runTest();
</script>
</body>
</html>

View File

@ -77,18 +77,12 @@
// Preferences
function() {
SpecialPowers.pushPrefEnv({"set": [["dom.datastore.enabled", true],
["dom.datastore.sysMsgOnChangeShortTimeoutSec", 1],
["dom.datastore.sysMsgOnChangeLongTimeoutSec", 3],
["dom.ipc.browser_frames.oop_by_default", true],
["dom.testing.ignore_ipc_principal", true],
["dom.testing.datastore_enabled_for_hosted_apps", true]]}, runTest);
},
function() {
if (SpecialPowers.isMainProcess()) {
SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
}
SpecialPowers.setAllAppsLaunchable(true);
SpecialPowers.setBoolPref("dom.mozBrowserFramesEnabled", true);
runTest();
@ -123,6 +117,10 @@
SimpleTest.finish();
}
if (SpecialPowers.isMainProcess()) {
SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
}
SimpleTest.waitForExplicitFinish();
runTest();
</script>

View File

@ -105,18 +105,12 @@
// Preferences
function() {
SpecialPowers.pushPrefEnv({"set": [["dom.datastore.enabled", true],
["dom.datastore.sysMsgOnChangeShortTimeoutSec", 1],
["dom.datastore.sysMsgOnChangeLongTimeoutSec", 3],
["dom.ipc.browser_frames.oop_by_default", true],
["dom.testing.ignore_ipc_principal", true],
["dom.testing.datastore_enabled_for_hosted_apps", true]]}, runTest);
},
function() {
if (SpecialPowers.isMainProcess()) {
SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
}
SpecialPowers.setAllAppsLaunchable(true);
SpecialPowers.setBoolPref("dom.mozBrowserFramesEnabled", true);
runTest();
@ -153,6 +147,10 @@
SimpleTest.finish();
}
if (SpecialPowers.isMainProcess()) {
SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
}
SimpleTest.waitForExplicitFinish();
runTest();
</script>

View File

@ -30,10 +30,6 @@
}
function runTest() {
if (SpecialPowers.isMainProcess()) {
SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
}
SpecialPowers.setAllAppsLaunchable(true);
SpecialPowers.setBoolPref("dom.mozBrowserFramesEnabled", true);
@ -99,10 +95,12 @@
SimpleTest.finish();
}
if (SpecialPowers.isMainProcess()) {
SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
}
SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({"set": [["dom.datastore.enabled", true],
["dom.datastore.sysMsgOnChangeShortTimeoutSec", 1],
["dom.datastore.sysMsgOnChangeLongTimeoutSec", 3],
["dom.testing.ignore_ipc_principal", true],
["dom.testing.datastore_enabled_for_hosted_apps", true]]}, runTest);
</script>

View File

@ -77,17 +77,11 @@
// Preferences
function() {
SpecialPowers.pushPrefEnv({"set": [["dom.datastore.enabled", true],
["dom.datastore.sysMsgOnChangeShortTimeoutSec", 1],
["dom.datastore.sysMsgOnChangeLongTimeoutSec", 3],
["dom.testing.ignore_ipc_principal", true],
["dom.testing.datastore_enabled_for_hosted_apps", true]]}, runTest);
},
function() {
if (SpecialPowers.isMainProcess()) {
SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
}
SpecialPowers.setBoolPref("dom.mozBrowserFramesEnabled", true);
runTest();
},
@ -121,6 +115,10 @@
SimpleTest.finish();
}
if (SpecialPowers.isMainProcess()) {
SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
}
SimpleTest.waitForExplicitFinish();
runTest();
</script>

View File

@ -77,17 +77,11 @@
// Preferences
function() {
SpecialPowers.pushPrefEnv({"set": [["dom.datastore.enabled", true],
["dom.datastore.sysMsgOnChangeShortTimeoutSec", 1],
["dom.datastore.sysMsgOnChangeLongTimeoutSec", 3],
["dom.testing.ignore_ipc_principal", true],
["dom.testing.datastore_enabled_for_hosted_apps", true]]}, runTest);
},
function() {
if (SpecialPowers.isMainProcess()) {
SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
}
SpecialPowers.setBoolPref("dom.mozBrowserFramesEnabled", true);
runTest();
},
@ -121,6 +115,10 @@
SimpleTest.finish();
}
if (SpecialPowers.isMainProcess()) {
SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
}
SimpleTest.waitForExplicitFinish();
runTest();
</script>

View File

@ -77,17 +77,11 @@
// Preferences
function() {
SpecialPowers.pushPrefEnv({"set": [["dom.datastore.enabled", true],
["dom.datastore.sysMsgOnChangeShortTimeoutSec", 1],
["dom.datastore.sysMsgOnChangeLongTimeoutSec", 3],
["dom.testing.ignore_ipc_principal", true],
["dom.testing.datastore_enabled_for_hosted_apps", true]]}, runTest);
},
function() {
if (SpecialPowers.isMainProcess()) {
SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
}
SpecialPowers.setAllAppsLaunchable(true);
SpecialPowers.setBoolPref("dom.mozBrowserFramesEnabled", true);
runTest();
@ -122,6 +116,10 @@
SimpleTest.finish();
}
if (SpecialPowers.isMainProcess()) {
SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
}
SimpleTest.waitForExplicitFinish();
runTest();
</script>

View File

@ -33,33 +33,33 @@ SimpleTest.waitForExplicitFinish();
function tests() {
synthesizeMouseAtCenter($("label1"), { type: "mousemove" });
yield undefined;
is($("button1").mozMatchesSelector(":hover"), true,
is($("button1").matches(":hover"), true,
"Button 1 should be hovered after mousemove over label1");
is($("label1").mozMatchesSelector(":hover"), true,
is($("label1").matches(":hover"), true,
"Label 1 should be hovered after mousemove over label1");
is($("button2").mozMatchesSelector(":hover"), false,
is($("button2").matches(":hover"), false,
"Button 2 should not be hovered after mousemove over label1");
is($("label2").mozMatchesSelector(":hover"), false,
is($("label2").matches(":hover"), false,
"Label 2 should not be hovered after mousemove over label1");
synthesizeMouseAtCenter($("button2"), { type: "mousemove" });
yield undefined;
is($("button1").mozMatchesSelector(":hover"), false,
is($("button1").matches(":hover"), false,
"Button 1 should not be hovered after mousemove over button2");
is($("label1").mozMatchesSelector(":hover"), false,
is($("label1").matches(":hover"), false,
"Label 1 should not be hovered after mousemove over button2");
is($("button2").mozMatchesSelector(":hover"), true,
is($("button2").matches(":hover"), true,
"Button 2 should be hovered after mousemove over button2");
is($("label2").mozMatchesSelector(":hover"), false,
is($("label2").matches(":hover"), false,
"Label 2 should not be hovered after mousemove over label2");
synthesizeMouseAtCenter($("label2"), { type: "mousemove" });
yield undefined;
is($("button1").mozMatchesSelector(":hover"), false,
is($("button1").matches(":hover"), false,
"Button 1 should not be hovered after mousemove over label2");
is($("label1").mozMatchesSelector(":hover"), false,
is($("label1").matches(":hover"), false,
"Label 1 should not be hovered after mousemove over label2");
is($("button2").mozMatchesSelector(":hover"), true,
is($("button2").matches(":hover"), true,
"Button 2 should be hovered after mousemove over label2");
is($("label2").mozMatchesSelector(":hover"), true,
is($("label2").matches(":hover"), true,
"Label 2 should be hovered after mousemove over label2");
SimpleTest.finish();
}

View File

@ -18,6 +18,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=960946
// The input context.
var gContext = null;
var gCounter = 0;
var gBackSpaceCounter = 0;
var result = ["keydown", "keypress", "keydown","keypress",
"keydown", "keypress", "keyup"
];
@ -26,11 +27,12 @@ inputmethod_setup(function() {
runTest();
});
var input;
// The frame script running in file_test_backspace_event.html.
function appFrameScript() {
let input = content.document.getElementById('test-input');
input.onkeydown = input.onkeypress = input.onkeyup = function(event) {
dump('key event was fired in file_test_backspace_event.html.\n');
dump('key event was fired in file_test_backspace_event.html: ' + event.type +'\n');
sendAsyncMessage('test:KeyBoard:keyEvent', {'type':event.type});
};
}
@ -67,9 +69,6 @@ function runTest() {
ok(true, 'Keyboard input was received.');
is(SpecialPowers.wrap(event).json.type, result[gCounter], "expected event");
gCounter++;
if (gCounter == 7) {
inputmethod_cleanup();
}
});
});
}
@ -93,6 +92,10 @@ function test_sendBackspace(repeat) {
// Send backspace
gContext.sendKey(KeyEvent.DOM_VK_BACK_SPACE, 0, 0, repeat).then(function() {
ok(true, 'sendKey success');
gBackSpaceCounter++;
if (gBackSpaceCounter == 3) {
inputmethod_cleanup();
}
}, function(e) {
ok(false, 'sendKey failed:' + e.name);
inputmethod_cleanup();

View File

@ -192,48 +192,31 @@ SystemMessageInternal.prototype = {
// clean it up from the pending message queue when apps receive it.
let messageID = gUUIDGenerator.generateUUID().toString();
let manifestURL = aManifestURI.spec;
let pageURLs = [];
if (aPageURI) {
pageURLs.push(aPageURI.spec);
} else {
// Send this message to all the registered pages of the app if |aPageURI|
// is not specified.
for (let i = 0; i < this._pages.length; i++) {
let page = this._pages[i];
if (page.type === aType && page.manifestURL === manifestURL) {
pageURLs.push(page.pageURL);
}
}
debug("Sending " + aType + " " + JSON.stringify(aMessage) +
" for " + aPageURI.spec + " @ " + aManifestURI.spec +
'; extra: ' + JSON.stringify(aExtra));
let result = this._sendMessageCommon(aType,
aMessage,
messageID,
aPageURI.spec,
aManifestURI.spec,
aExtra);
debug("Returned status of sending message: " + result);
// Don't need to open the pages and queue the system message
// which was not allowed to be sent.
if (result === MSG_SENT_FAILURE_PERM_DENIED) {
return;
}
pageURLs.forEach(function(aPageURL) {
debug("Sending " + aType + " " + JSON.stringify(aMessage) +
" for " + aPageURL + " @ " + manifestURL +
'; extra: ' + JSON.stringify(aExtra));
let page = this._findPage(aType, aPageURI.spec, aManifestURI.spec);
if (page) {
// Queue this message in the corresponding pages.
this._queueMessage(page, aMessage, messageID);
let result = this._sendMessageCommon(aType,
aMessage,
messageID,
aPageURL,
manifestURL,
aExtra);
debug("Returned status of sending message: " + result);
// Don't need to open the pages and queue the system message
// which was not allowed to be sent.
if (result === MSG_SENT_FAILURE_PERM_DENIED) {
return;
}
let page = this._findPage(aType, aPageURL, manifestURL);
if (page) {
// Queue this message in the corresponding pages.
this._queueMessage(page, aMessage, messageID);
this._openAppPage(page, aMessage, aExtra, result);
}
}, this);
this._openAppPage(page, aMessage, aExtra, result);
}
},
broadcastMessage: function(aType, aMessage, aExtra) {

View File

@ -15,8 +15,7 @@ Cu.import("resource://gre/modules/PermissionsTable.jsm");
Cu.import("resource://gre/modules/PermissionSettings.jsm");
this.EXPORTED_SYMBOLS = ["SystemMessagePermissionsChecker",
"SystemMessagePermissionsTable",
"SystemMessagePrefixPermissionsTable"];
"SystemMessagePermissionsTable"];
function debug(aStr) {
// dump("SystemMessagePermissionsChecker.jsm: " + aStr + "\n");
@ -123,18 +122,6 @@ this.SystemMessagePermissionsTable = {
}
};
// This table maps system message prefix to permission(s), indicating only
// the system messages with specified prefixes granted by the page's permissions
// are allowed to be registered or sent to that page. Note the empty permission
// set means this type of system message is always permitted.
//
// Note that this table is only used when the permission checker can't find a
// match in SystemMessagePermissionsTable listed above.
this.SystemMessagePrefixPermissionsTable = {
"datastore-update-": { },
};
this.SystemMessagePermissionsChecker = {
/**
* Return all the needed permission names for the given system message.
@ -153,26 +140,16 @@ this.SystemMessagePermissionsChecker = {
let permNames = SystemMessagePermissionsTable[aSysMsgName];
if (permNames === undefined) {
// Try to look up in the prefix table.
for (let sysMsgPrefix in SystemMessagePrefixPermissionsTable) {
if (aSysMsgName.indexOf(sysMsgPrefix) === 0) {
permNames = SystemMessagePrefixPermissionsTable[sysMsgPrefix];
break;
}
}
if (permNames === undefined) {
debug("'" + aSysMsgName + "' is not associated with permissions. " +
"Please add them to the SystemMessage[Prefix]PermissionsTable.");
return null;
}
debug("'" + aSysMsgName + "' is not associated with permissions. " +
"Please add them to the SystemMessagePermissionsTable.");
return null;
}
let object = { };
for (let permName in permNames) {
if (PermissionsTable[permName] === undefined) {
debug("'" + permName + "' for '" + aSysMsgName + "' is invalid. " +
"Please correct it in the SystemMessage[Prefix]PermissionsTable.");
"Please correct it in the SystemMessagePermissionsTable.");
return null;
}
@ -180,7 +157,7 @@ this.SystemMessagePermissionsChecker = {
let access = permNames[permName];
if (!access || !Array.isArray(access)) {
debug("'" + permName + "' is not associated with access array. " +
"Please correct it in the SystemMessage[Prefix]PermissionsTable.");
"Please correct it in the SystemMessagePermissionsTable.");
return null;
}
object[permName] = appendAccessToPermName(permName, access);

View File

@ -13,12 +13,10 @@ interface nsIDOMWindow;
interface nsISystemMessagesInternal : nsISupports
{
/*
* Allow any internal user to send a message of a given type to a given page
* of an app. The message will be sent to all the registered pages of the app
* when |pageURI| is not specified.
* Allow any internal user to broadcast a message of a given type.
* @param type The type of the message to be sent.
* @param message The message payload.
* @param pageURI The URI of the page that will be opened. Nullable.
* @param pageURI The URI of the page that will be opened.
* @param manifestURI The webapp's manifest URI.
* @param extra Extra opaque information that will be passed around in the observer
* notification to open the page.

View File

@ -1538,6 +1538,9 @@ static bool
NPObjWrapper_NewResolve(JSContext *cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id,
JS::MutableHandle<JSObject*> objp)
{
if (JSID_IS_SYMBOL(id))
return true;
NPObject *npobj = GetNPObject(cx, obj);
if (!npobj || !npobj->_class || !npobj->_class->hasProperty ||

View File

@ -31,7 +31,7 @@ PluginIdentifierParent::RecvRetain()
// Intern the jsid if necessary.
AutoSafeJSContext cx;
JS::Rooted<jsid> id(cx, NPIdentifierToJSId(mIdentifier));
if (JSID_IS_INT(id)) {
if (!JSID_IS_STRING(id)) {
return true;
}

View File

@ -46,8 +46,6 @@
let mm1 = flo1.frameLoader.messageManager;
let mm2 = flo2.frameLoader.messageManager;
mm1.addMessageListener("pong", () => { gotPong(true); });
mm2.addMessageListener("pong", () => { gotPong(false); });
// Swap docshells. Everything should be identical to before, since there was nothing to
// distinguish these docshells.

View File

@ -478,6 +478,8 @@ WEBIDL_FILES = [
'VTTRegion.webidl',
'WaveShaperNode.webidl',
'WebComponents.webidl',
'WebGL2RenderingContext.webidl',
'WebGLRenderingContext.webidl',
'WebSocket.webidl',
'WheelEvent.webidl',
'WifiOptions.webidl',
@ -504,12 +506,6 @@ if CONFIG['MOZ_AUDIO_CHANNEL_MANAGER']:
'AudioChannelManager.webidl',
]
if CONFIG['MOZ_WEBGL']:
WEBIDL_FILES += [
'WebGL2RenderingContext.webidl',
'WebGLRenderingContext.webidl',
]
if CONFIG['MOZ_WEBRTC']:
WEBIDL_FILES += [
'DataChannel.webidl',

View File

@ -4,10 +4,7 @@ this.Test = {
start: function(ok, is, finish) {
let worker = new ChromeWorker("jsm_url_worker.js");
worker.onmessage = function(event) {
if (event.data.type == 'finish') {
finish();
} else if (event.data.type == 'status') {
if (event.data.type == 'status') {
ok(event.data.status, event.data.msg);
} else if (event.data.type == 'url') {
var xhr = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]
@ -16,8 +13,13 @@ this.Test = {
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
ok(true, "Blob readable!");
finish();
}
}
xhr.onerror = function() {
ok(true, "Blob unreadable, should not happen!");
finish();
}
xhr.send();
}
};

View File

@ -27,7 +27,6 @@
#include "skia/SkLayerDrawLooper.h"
#include "skia/SkDashPathEffect.h"
#include "Logging.h"
#include "HelpersSkia.h"
#include "Tools.h"
#include "DataSurfaceHelpers.h"
#include <algorithm>
@ -108,9 +107,15 @@ GetBitmapForSurface(SourceSurface* aSurface)
MOZ_CRASH("Non-skia SourceSurfaces need to be DataSourceSurfaces");
}
result.mBitmap.setConfig(GfxFormatToSkiaConfig(surf->GetFormat()),
surf->GetSize().width, surf->GetSize().height,
surf->Stride());
SkAlphaType alphaType = (surf->GetFormat() == SurfaceFormat::B8G8R8X8) ?
kOpaque_SkAlphaType : kPremul_SkAlphaType;
SkImageInfo info = SkImageInfo::Make(surf->GetSize().width,
surf->GetSize().height,
GfxFormatToSkiaColorType(surf->GetFormat()),
alphaType);
result.mBitmap.setInfo(info, surf->Stride());
result.mBitmap.setPixels(surf->GetData());
result.mTmpSurface = surf.forget();
return result;
@ -168,8 +173,9 @@ SetPaintPattern(SkPaint& aPaint, const Pattern& aPattern, TempBitmap& aTmpBitmap
if (shader) {
SkMatrix mat;
GfxMatrixToSkiaMatrix(pat.mMatrix, mat);
shader->setLocalMatrix(mat);
SkSafeUnref(aPaint.setShader(shader));
SkShader* matrixShader = SkShader::CreateLocalMatrixShader(shader, mat);
SkSafeUnref(shader);
SkSafeUnref(aPaint.setShader(matrixShader));
}
} else {
@ -198,8 +204,9 @@ SetPaintPattern(SkPaint& aPaint, const Pattern& aPattern, TempBitmap& aTmpBitmap
if (shader) {
SkMatrix mat;
GfxMatrixToSkiaMatrix(pat.mMatrix, mat);
shader->setLocalMatrix(mat);
SkSafeUnref(aPaint.setShader(shader));
SkShader* matrixShader = SkShader::CreateLocalMatrixShader(shader, mat);
SkSafeUnref(shader);
SkSafeUnref(aPaint.setShader(matrixShader));
}
} else {
@ -216,8 +223,9 @@ SetPaintPattern(SkPaint& aPaint, const Pattern& aPattern, TempBitmap& aTmpBitmap
SkShader* shader = SkShader::CreateBitmapShader(bitmap, mode, mode);
SkMatrix mat;
GfxMatrixToSkiaMatrix(pat.mMatrix, mat);
shader->setLocalMatrix(mat);
SkSafeUnref(aPaint.setShader(shader));
SkShader* matrixShader = SkShader::CreateLocalMatrixShader(shader, mat);
SkSafeUnref(shader);
SkSafeUnref(aPaint.setShader(matrixShader));
if (pat.mFilter == Filter::POINT) {
aPaint.setFilterLevel(SkPaint::kNone_FilterLevel);
}
@ -375,7 +383,7 @@ DrawTargetSkia::DrawSurfaceWithShadow(SourceSurface *aSurface,
MarkChanged();
mCanvas->save(SkCanvas::kMatrix_SaveFlag);
mCanvas->save();
mCanvas->resetMatrix();
TempBitmap bitmap = GetBitmapForSurface(aSurface);
@ -383,7 +391,8 @@ DrawTargetSkia::DrawSurfaceWithShadow(SourceSurface *aSurface,
SkPaint paint;
SkImageFilter* filter = SkDropShadowImageFilter::Create(aOffset.x, aOffset.y,
aSigma, ColorToSkColor(aColor, 1.0));
aSigma, aSigma,
ColorToSkColor(aColor, 1.0));
paint.setImageFilter(filter);
paint.setXfermodeMode(GfxOpToSkiaOp(aOperator));
@ -575,7 +584,8 @@ DrawTargetSkia::MaskSurface(const Pattern &aSource,
SkMatrix transform = maskPaint.getShader()->getLocalMatrix();
transform.postTranslate(SkFloatToScalar(aOffset.x), SkFloatToScalar(aOffset.y));
maskPaint.getShader()->setLocalMatrix(transform);
SkShader* matrixShader = SkShader::CreateLocalMatrixShader(maskPaint.getShader(), transform);
maskPaint.setShader(matrixShader);
SkLayerRasterizer::Builder builder;
builder.addLayer(maskPaint);
@ -687,7 +697,7 @@ DrawTargetSkia::CopySurface(SourceSurface *aSurface,
TempBitmap bitmap = GetBitmapForSurface(aSurface);
// This is a fast path that is disabled for now to mimimize risk
if (false && !bitmap.mBitmap.getTexture() && mCanvas->getDevice()->config() == bitmap.mBitmap.config()) {
if (false && !bitmap.mBitmap.getTexture() && mCanvas->imageInfo() == bitmap.mBitmap.info()) {
SkBitmap bm(bitmap.mBitmap);
bm.lockPixels();
if (bm.getPixels()) {
@ -709,7 +719,7 @@ DrawTargetSkia::CopySurface(SourceSurface *aSurface,
mCanvas->clipRect(dest, SkRegion::kReplace_Op);
SkPaint paint;
if (mCanvas->getDevice()->config() == SkBitmap::kRGB_565_Config) {
if (mCanvas->imageInfo().colorType() == kRGB_565_SkColorType) {
// Set the xfermode to SOURCE_OVER to workaround
// http://code.google.com/p/skia/issues/detail?id=628
// RGB565 is opaque so they're equivalent anyway
@ -719,7 +729,7 @@ DrawTargetSkia::CopySurface(SourceSurface *aSurface,
}
// drawBitmapRect with A8 bitmaps ends up doing a mask operation
// so we need to clear before
if (bitmap.mBitmap.config() == SkBitmap::kA8_Config) {
if (bitmap.mBitmap.colorType() == kAlpha_8_SkColorType) {
SkPaint clearPaint;
clearPaint.setColor(SkColorSetARGB(0, 0, 0, 0));
clearPaint.setXfermodeMode(SkXfermode::kSrc_Mode);
@ -752,10 +762,9 @@ DrawTargetSkia::Init(const IntSize &aSize, SurfaceFormat aFormat)
bitmap.eraseARGB(0, 0, 0, 0);
SkAutoTUnref<SkCanvas> canvas(new SkCanvas(device.get()));
mCanvas.adopt(new SkCanvas(device.get()));
mSize = aSize;
mCanvas = canvas.get();
mFormat = aFormat;
return true;
}
@ -769,7 +778,6 @@ DrawTargetSkia::InitWithGrContext(GrContext* aGrContext,
MOZ_ASSERT(aGrContext, "null GrContext");
mGrContext = aGrContext;
mSize = aSize;
mFormat = aFormat;
@ -790,8 +798,7 @@ DrawTargetSkia::InitWithGrContext(GrContext* aGrContext,
mTexture = (uint32_t)skiaTexture->getTextureHandle();
SkAutoTUnref<SkBaseDevice> device(new SkGpuDevice(mGrContext.get(), skiaTexture->asRenderTarget()));
SkAutoTUnref<SkCanvas> canvas(new SkCanvas(device.get()));
mCanvas = canvas.get();
mCanvas.adopt(new SkCanvas(device.get()));
return true;
}
@ -809,12 +816,16 @@ DrawTargetSkia::Init(unsigned char* aData, const IntSize &aSize, int32_t aStride
}
SkBitmap bitmap;
bitmap.setConfig(GfxFormatToSkiaConfig(aFormat), aSize.width, aSize.height, aStride, alphaType);
SkImageInfo info = SkImageInfo::Make(aSize.width,
aSize.height,
GfxFormatToSkiaColorType(aFormat),
alphaType);
bitmap.setInfo(info, aStride);
bitmap.setPixels(aData);
SkAutoTUnref<SkCanvas> canvas(new SkCanvas(new SkBitmapDevice(bitmap)));
mCanvas.adopt(new SkCanvas(new SkBitmapDevice(bitmap)));
mSize = aSize;
mCanvas = canvas.get();
mFormat = aFormat;
}
@ -865,7 +876,7 @@ DrawTargetSkia::PushClip(const Path *aPath)
}
const PathSkia *skiaPath = static_cast<const PathSkia*>(aPath);
mCanvas->save(SkCanvas::kClip_SaveFlag);
mCanvas->save();
mCanvas->clipPath(skiaPath->GetPath(), SkRegion::kIntersect_Op, true);
}
@ -874,7 +885,7 @@ DrawTargetSkia::PushClipRect(const Rect& aRect)
{
SkRect rect = RectToSkRect(aRect);
mCanvas->save(SkCanvas::kClip_SaveFlag);
mCanvas->save();
mCanvas->clipRect(rect, SkRegion::kIntersect_Op, true);
}

View File

@ -14,6 +14,7 @@
#include "skia/SkCanvas.h"
#include "2D.h"
#include "HelpersSkia.h"
#include "Rect.h"
#include "PathSkia.h"
#include <sstream>
@ -130,12 +131,12 @@ private:
bool UsingSkiaGPU() const;
#ifdef USE_SKIA_GPU
SkRefPtr<GrContext> mGrContext;
RefPtrSkia<GrContext> mGrContext;
uint32_t mTexture;
#endif
IntSize mSize;
SkRefPtr<SkCanvas> mCanvas;
RefPtrSkia<SkCanvas> mCanvas;
SourceSurfaceSkia* mSnapshot;
};

View File

@ -38,6 +38,22 @@ GfxFormatToSkiaConfig(SurfaceFormat format)
}
}
static inline SurfaceFormat
SkiaConfigToGfxFormat(SkBitmap::Config config)
{
switch (config)
{
case SkBitmap::kARGB_8888_Config:
return SurfaceFormat::B8G8R8A8;
case SkBitmap::kRGB_565_Config:
return SurfaceFormat::R5G6B5;
case SkBitmap::kA8_Config:
return SurfaceFormat::A8;
default:
return SurfaceFormat::B8G8R8A8;
}
}
static inline SkColorType
GfxFormatToSkiaColorType(SurfaceFormat format)
{
@ -58,15 +74,15 @@ GfxFormatToSkiaColorType(SurfaceFormat format)
}
static inline SurfaceFormat
SkiaConfigToGfxFormat(SkBitmap::Config config)
SkiaColorTypeToGfxFormat(SkColorType type)
{
switch (config)
switch (type)
{
case SkBitmap::kARGB_8888_Config:
case kBGRA_8888_SkColorType:
return SurfaceFormat::B8G8R8A8;
case SkBitmap::kRGB_565_Config:
case kRGB_565_SkColorType:
return SurfaceFormat::R5G6B5;
case SkBitmap::kA8_Config:
case kAlpha_8_SkColorType:
return SurfaceFormat::A8;
default:
return SurfaceFormat::B8G8R8A8;
@ -306,6 +322,74 @@ ExtendModeToTileMode(ExtendMode aMode)
return SkShader::kClamp_TileMode;
}
// The following class was imported from Skia, which is under the
// following licence:
//
// Copyright (c) 2011 Google Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
template <typename T> class RefPtrSkia {
public:
RefPtrSkia() : fObj(NULL) {}
RefPtrSkia(T* obj) : fObj(obj) { SkSafeRef(fObj); }
RefPtrSkia(const RefPtrSkia& o) : fObj(o.fObj) { SkSafeRef(fObj); }
~RefPtrSkia() { SkSafeUnref(fObj); }
RefPtrSkia& operator=(const RefPtrSkia& rp) {
SkRefCnt_SafeAssign(fObj, rp.fObj);
return *this;
}
RefPtrSkia& operator=(T* obj) {
SkRefCnt_SafeAssign(fObj, obj);
return *this;
}
T* get() const { return fObj; }
T& operator*() const { return *fObj; }
T* operator->() const { return fObj; }
RefPtrSkia& adopt(T* obj) {
SkSafeUnref(fObj);
fObj = obj;
return *this;
}
typedef T* RefPtrSkia::*unspecified_bool_type;
operator unspecified_bool_type() const {
return fObj ? &RefPtrSkia::fObj : NULL;
}
private:
T* fObj;
};
// End of code imported from Skia.
}
}

View File

@ -25,15 +25,17 @@ bool Scale(uint8_t* srcData, int32_t srcWidth, int32_t srcHeight, int32_t srcStr
alphaType = kOpaque_SkAlphaType;
}
SkBitmap::Config config = GfxFormatToSkiaConfig(format);
SkImageInfo info = SkImageInfo::Make(srcWidth,
srcHeight,
GfxFormatToSkiaColorType(format),
alphaType);
SkBitmap imgSrc;
imgSrc.setConfig(config, srcWidth, srcHeight, srcStride, alphaType);
imgSrc.setPixels(srcData);
imgSrc.installPixels(info, srcData, srcStride);
// Rescaler is compatible with 32 bpp only. Convert to RGB32 if needed.
if (config != SkBitmap::kARGB_8888_Config) {
imgSrc.copyTo(&imgSrc, kRGBA_8888_SkColorType);
if (format != SurfaceFormat::B8G8R8A8) {
imgSrc.copyTo(&imgSrc, kBGRA_8888_SkColorType);
}
// This returns an SkBitmap backed by dstData; since it also wrote to dstData,

View File

@ -7,7 +7,6 @@
#ifdef USE_SKIA
#include "PathSkia.h"
#include "skia/SkEmptyShader.h"
#include "skia/SkPaint.h"
#endif

View File

@ -65,7 +65,14 @@ SourceSurfaceSkia::InitFromData(unsigned char* aData,
SurfaceFormat aFormat)
{
SkBitmap temp;
temp.setConfig(GfxFormatToSkiaConfig(aFormat), aSize.width, aSize.height, aStride);
SkAlphaType alphaType = (aFormat == SurfaceFormat::B8G8R8X8) ?
kOpaque_SkAlphaType : kPremul_SkAlphaType;
SkImageInfo info = SkImageInfo::Make(aSize.width,
aSize.height,
GfxFormatToSkiaColorType(aFormat),
alphaType);
temp.setInfo(info, aStride);
temp.setPixels(aData);
if (!temp.copyTo(&mBitmap, GfxFormatToSkiaColorType(aFormat))) {

View File

@ -408,9 +408,13 @@ SkBitmap ImageOperations::ResizeSubpixel(const SkBitmap& source,
// Render into subpixels.
SkBitmap result;
result.setConfig(SkBitmap::kARGB_8888_Config, dest_subset.width(),
dest_subset.height());
result.allocPixels();
SkImageInfo info = SkImageInfo::Make(dest_subset.width(),
dest_subset.height(),
kBGRA_8888_SkColorType,
kPremul_SkAlphaType);
result.allocPixels(info);
if (!result.readyToDraw())
return img;
@ -515,13 +519,15 @@ SkBitmap ImageOperations::ResizeBasic(const SkBitmap& source,
// Convolve into the result.
SkBitmap result;
result.setConfig(SkBitmap::kARGB_8888_Config,
dest_subset.width(), dest_subset.height());
SkImageInfo info = SkImageInfo::Make(dest_subset.width(),
dest_subset.height(),
kBGRA_8888_SkColorType,
kPremul_SkAlphaType);
if (dest_pixels) {
result.setPixels(dest_pixels);
result.installPixels(info, dest_pixels, info.minRowBytes());
} else {
result.allocPixels();
result.allocPixels(info);
}
if (!result.readyToDraw())

View File

@ -75,6 +75,9 @@ if CONFIG['MOZ_ENABLE_SKIA']:
SOURCES += [
'image_operations.cpp', # Uses _USE_MATH_DEFINES
]
EXPORTS.mozilla.gfx += [
'HelpersSkia.h',
]
# Are we targeting x86 or x64? If so, build SSE2 files.
if CONFIG['INTEL_ARCHITECTURE']:

View File

@ -114,7 +114,6 @@ GLLibraryEGL::EnsureInitialized()
#endif
#ifdef XP_WIN
#ifdef MOZ_WEBGL
if (!mEGLLibrary) {
// On Windows, the GLESv2, EGL and DXSDK libraries are shipped with libxul and
// we should look for them there. We have to load the libs in this
@ -153,7 +152,7 @@ GLLibraryEGL::EnsureInitialized()
if (!mEGLLibrary)
return false;
}
#endif // MOZ_WEBGL
#else // !Windows
// On non-Windows (Android) we use system copies of libEGL. We look for

View File

@ -730,33 +730,6 @@ GrGLvoid glGenVertexArrays_mozilla(GrGLsizei n, GrGLuint *arrays) {
return sGLContext.get()->fGenVertexArrays(n, arrays);
}
// Additional functions required for desktop GL < version 3.2
GrGLvoid glLoadMatrixf_mozilla(const GLfloat* matrix)
{
return sGLContext.get()->fLoadMatrixf(matrix);
}
GrGLvoid glLoadIdentity_mozilla()
{
return sGLContext.get()->fLoadIdentity();
}
GrGLvoid glMatrixMode_mozilla(GrGLenum mode)
{
return sGLContext.get()->fMatrixMode(mode);
}
GrGLvoid glTexGeni_mozilla(GrGLenum coord, GrGLenum pname, GrGLint param)
{
return sGLContext.get()->fTexGeni(coord, pname, param);
}
GrGLvoid glTexGenfv_mozilla(GrGLenum coord, GrGLenum pname, const GrGLfloat* param)
{
return sGLContext.get()->fTexGenfv(coord, pname, param);
}
} // extern "C"
static GrGLInterface* CreateGrGLInterfaceFromGLContext(GLContext* context)
@ -916,23 +889,13 @@ static GrGLInterface* CreateGrGLInterfaceFromGLContext(GLContext* context)
// Desktop OpenGL > 2.0
i->fFunctions.fDrawBuffers = glDrawBuffers_mozilla;
// Desktop OpenGL < 3.2 (which we pretend to be)
i->fFunctions.fLoadIdentity = glLoadIdentity_mozilla;
i->fFunctions.fLoadMatrixf = glLoadMatrixf_mozilla;
i->fFunctions.fMatrixMode = glMatrixMode_mozilla;
i->fFunctions.fTexGenfv = glTexGenfv_mozilla;
i->fFunctions.fTexGeni = glTexGeni_mozilla;
return i;
}
SkiaGLGlue::SkiaGLGlue(GLContext* context)
: mGLContext(context)
{
SkAutoTUnref<GrGLInterface> i(CreateGrGLInterfaceFromGLContext(mGLContext));
i->fCallbackData = reinterpret_cast<GrGLInterfaceCallbackData>(this);
mGrGLInterface = i;
SkAutoTUnref<GrContext> gr(GrContext::Create(kOpenGL_GrBackend, (GrBackendContext)mGrGLInterface.get()));
mGrContext = gr;
mGrGLInterface.adopt(CreateGrGLInterfaceFromGLContext(mGLContext));
mGrGLInterface->fCallbackData = reinterpret_cast<GrGLInterfaceCallbackData>(this);
mGrContext.adopt(GrContext::Create(kOpenGL_GrBackend, (GrBackendContext)mGrGLInterface.get()));
}

View File

@ -10,6 +10,7 @@
#include "GLContext.h"
#include "skia/GrGLInterface.h"
#include "skia/GrContext.h"
#include "mozilla/gfx/HelpersSkia.h"
namespace mozilla {
namespace gl {
@ -36,8 +37,8 @@ protected:
private:
RefPtr<GLContext> mGLContext;
SkRefPtr<GrGLInterface> mGrGLInterface;
SkRefPtr<GrContext> mGrContext;
mozilla::gfx::RefPtrSkia<GrGLInterface> mGrGLInterface;
mozilla::gfx::RefPtrSkia<GrContext> mGrContext;
};
}

View File

@ -2,7 +2,7 @@ The source from this directory was copied from the skia subversion trunk
using the update.sh script. The changes made were those applied by update.sh,
the addition/update of Makefile.in files for the Mozilla build system.
The subversion revision used was r13827.
This is an import of Skia from 2014-07-28 (b1ab5fdd11bb358d738c1bfa63737dc65174a281)
To update to a new version of Skia:

Some files were not shown because too many files have changed in this diff Show More