From b5f8fa64790d0ef75bfd79e72c9cd4a4098277f5 Mon Sep 17 00:00:00 2001 From: FranklinDM Date: Fri, 6 Jan 2023 21:07:37 +0800 Subject: Issue #2084 - Part 1: Remove CSSUnprefixingService.js and associated code It's effectively dead code since it's been supplanted by built-in webkit-prefixed-CSS support (landed before fork point in Firefox 49). Based on https://bugzilla.mozilla.org/show_bug.cgi?id=1259348 --- layout/style/CSSUnprefixingService.js | 341 ------------------ layout/style/CSSUnprefixingService.manifest | 2 - layout/style/moz.build | 11 - layout/style/nsCSSParser.cpp | 215 +---------- layout/style/nsICSSUnprefixingService.idl | 76 ---- layout/style/test/mochitest.ini | 4 - layout/style/test/test_unprefixing_service.html | 93 ----- .../style/test/test_unprefixing_service_prefs.html | 132 ------- layout/style/test/unprefixing_service_iframe.html | 394 --------------------- layout/style/test/unprefixing_service_utils.js | 87 ----- 10 files changed, 11 insertions(+), 1344 deletions(-) delete mode 100644 layout/style/CSSUnprefixingService.js delete mode 100644 layout/style/CSSUnprefixingService.manifest delete mode 100644 layout/style/nsICSSUnprefixingService.idl delete mode 100644 layout/style/test/test_unprefixing_service.html delete mode 100644 layout/style/test/test_unprefixing_service_prefs.html delete mode 100644 layout/style/test/unprefixing_service_iframe.html delete mode 100644 layout/style/test/unprefixing_service_utils.js (limited to 'layout') diff --git a/layout/style/CSSUnprefixingService.js b/layout/style/CSSUnprefixingService.js deleted file mode 100644 index f6c63a0237..0000000000 --- a/layout/style/CSSUnprefixingService.js +++ /dev/null @@ -1,341 +0,0 @@ -/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- / -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* Implementation of a service that converts certain vendor-prefixed CSS - properties to their unprefixed equivalents, for sites on a whitelist. */ - -"use strict"; - -const Cc = Components.classes; -const Ci = Components.interfaces; -const Cu = Components.utils; - -Cu.import("resource://gre/modules/XPCOMUtils.jsm"); - -function CSSUnprefixingService() { -} - -CSSUnprefixingService.prototype = { - // Boilerplate: - classID: Components.ID("{f0729490-e15c-4a2f-a3fb-99e1cc946b42}"), - _xpcom_factory: XPCOMUtils.generateSingletonFactory(CSSUnprefixingService), - QueryInterface: XPCOMUtils.generateQI([Ci.nsICSSUnprefixingService]), - - // See documentation in nsICSSUnprefixingService.idl - generateUnprefixedDeclaration: function(aPropName, aRightHalfOfDecl, - aUnprefixedDecl /*out*/) { - - // Convert our input strings to lower-case, for easier string-matching. - // (NOTE: If we ever need to add support for unprefixing properties that - // have case-sensitive parts, then we should do these toLowerCase() - // conversions in a more targeted way, to avoid breaking those properties.) - aPropName = aPropName.toLowerCase(); - aRightHalfOfDecl = aRightHalfOfDecl.toLowerCase(); - - // We have several groups of supported properties: - // FIRST GROUP: Properties that can just be handled as aliases: - // ============================================================ - const propertiesThatAreJustAliases = { - "-webkit-background-size": "background-size", - "-webkit-box-flex": "flex-grow", - "-webkit-box-ordinal-group": "order", - "-webkit-box-sizing": "box-sizing", - "-webkit-transform": "transform", - "-webkit-transform-origin": "transform-origin", - }; - - let unprefixedPropName = propertiesThatAreJustAliases[aPropName]; - if (unprefixedPropName !== undefined) { - aUnprefixedDecl.value = unprefixedPropName + ":" + aRightHalfOfDecl; - return true; - } - - // SECOND GROUP: Properties that take a single keyword, where the - // unprefixed version takes a different (but analogous) set of keywords: - // ===================================================================== - const propertiesThatNeedKeywordMapping = { - "-webkit-box-align" : { - unprefixedPropName : "align-items", - valueMap : { - "start" : "flex-start", - "center" : "center", - "end" : "flex-end", - "baseline" : "baseline", - "stretch" : "stretch" - } - }, - "-webkit-box-orient" : { - unprefixedPropName : "flex-direction", - valueMap : { - "horizontal" : "row", - "inline-axis" : "row", - "vertical" : "column", - "block-axis" : "column" - } - }, - "-webkit-box-pack" : { - unprefixedPropName : "justify-content", - valueMap : { - "start" : "flex-start", - "center" : "center", - "end" : "flex-end", - "justify" : "space-between" - } - }, - }; - - let propInfo = propertiesThatNeedKeywordMapping[aPropName]; - if (typeof(propInfo) != "undefined") { - // Regexp for parsing the right half of a declaration, for keyword-valued - // properties. Divides the right half of the declaration into: - // 1) any leading whitespace - // 2) the property value (one or more alphabetical character or hyphen) - // 3) anything after that (e.g. "!important", ";") - // Then we can look up the appropriate unprefixed-property value for the - // value (part 2), and splice that together with the other parts and with - // the unprefixed property-name to make the final declaration. - const keywordValuedPropertyRegexp = /^(\s*)([a-z\-]+)(.*)/; - let parts = keywordValuedPropertyRegexp.exec(aRightHalfOfDecl); - if (!parts) { - // Failed to parse a keyword out of aRightHalfOfDecl. (It probably has - // no alphabetical characters.) - return false; - } - - let mappedKeyword = propInfo.valueMap[parts[2]]; - if (mappedKeyword === undefined) { - // We found a keyword in aRightHalfOfDecl, but we don't have a mapping - // to an equivalent keyword for the unprefixed version of the property. - return false; - } - - aUnprefixedDecl.value = propInfo.unprefixedPropName + ":" + - parts[1] + // any leading whitespace - mappedKeyword + - parts[3]; // any trailing text (e.g. !important, semicolon, etc) - - return true; - } - - // THIRD GROUP: Properties that may need arbitrary string-replacement: - // =================================================================== - const propertiesThatNeedStringReplacement = { - // "-webkit-transition" takes a multi-part value. If "-webkit-transform" - // appears as part of that value, replace it w/ "transform". - // And regardless, we unprefix the "-webkit-transition" property-name. - // (We could handle other prefixed properties in addition to 'transform' - // here, but in practice "-webkit-transform" is the main one that's - // likely to be transitioned & that we're concerned about supporting.) - "-webkit-transition": { - unprefixedPropName : "transition", - stringMap : { - "-webkit-transform" : "transform", - } - }, - }; - - propInfo = propertiesThatNeedStringReplacement[aPropName]; - if (typeof(propInfo) != "undefined") { - let newRightHalf = aRightHalfOfDecl; - for (let strToReplace in propInfo.stringMap) { - let replacement = propInfo.stringMap[strToReplace]; - newRightHalf = newRightHalf.split(strToReplace).join(replacement); - } - aUnprefixedDecl.value = propInfo.unprefixedPropName + ":" + newRightHalf; - - return true; - } - - // No known mapping for property aPropName. - return false; - }, - - // See documentation in nsICSSUnprefixingService.idl - generateUnprefixedGradientValue: function(aPrefixedFuncName, - aPrefixedFuncBody, - aUnprefixedFuncName, /*[out]*/ - aUnprefixedFuncBody /*[out]*/) { - var unprefixedFuncName, newValue; - if (aPrefixedFuncName == "-webkit-gradient") { - // Create expression for oldGradientParser: - var parts = this.oldGradientParser(aPrefixedFuncBody); - var type = parts[0].name; - newValue = this.standardizeOldGradientArgs(type, parts.slice(1)); - unprefixedFuncName = type + "-gradient"; - }else{ // we're dealing with more modern syntax - should be somewhat easier, at least for linear gradients. - // Fix three things: remove -webkit-, add 'to ' before reversed top/bottom keywords (linear) or 'at ' before position keywords (radial), recalculate deg-values - // -webkit-linear-gradient( [ [ | [top | bottom] || [left | right] ],]? [, ]+); - if (aPrefixedFuncName != "-webkit-linear-gradient" && - aPrefixedFuncName != "-webkit-radial-gradient") { - // Unrecognized prefixed gradient type - return false; - } - unprefixedFuncName = aPrefixedFuncName.replace(/-webkit-/, ''); - - // Keywords top, bottom, left, right: can be stand-alone or combined pairwise but in any order ('top left' or 'left top') - // These give the starting edge or corner in the -webkit syntax. The standardised equivalent is 'to ' plus opposite values for linear gradients, 'at ' plus same values for radial gradients - if(unprefixedFuncName.indexOf('linear') > -1){ - newValue = aPrefixedFuncBody.replace(/(top|bottom|left|right)+\s*(top|bottom|left|right)*/, function(str){ - var words = str.split(/\s+/); - for(var i=0; iIsOnCSSUnprefixingWhitelist(); -} - -bool -CSSParserImpl::ParsePropertyWithUnprefixingService( - const nsAString& aPropertyName, - css::Declaration* aDeclaration, - uint32_t aFlags, - bool aMustCallValueAppended, - bool* aChanged, - nsCSSContextType aContext) -{ - MOZ_ASSERT(ShouldUseUnprefixingService(), - "Caller should've checked ShouldUseUnprefixingService()"); - - nsCOMPtr unprefixingSvc = - do_GetService(NS_CSSUNPREFIXINGSERVICE_CONTRACTID); - NS_ENSURE_TRUE(unprefixingSvc, false); - - // Save the state so we can jump back to this spot if our unprefixing fails - // (so we can behave as if we didn't even try to unprefix). - nsAutoCSSParserInputStateRestorer parserStateBeforeTryingToUnprefix(this); - - // Caller has already parsed the first half of the declaration -- - // aPropertyName and the ":". Now, we record the rest of the CSS declaration - // (the part after ':') into rightHalfOfDecl. (This is the property value, - // plus anything else up to the end of the declaration -- maybe "!important", - // maybe trailing junk characters, maybe a semicolon, maybe a trailing "}".) - bool checkForBraces = (aFlags & eParseDeclaration_InBraces) != 0; - nsAutoString rightHalfOfDecl; - mScanner->StartRecording(); - SkipDeclaration(checkForBraces); - mScanner->StopRecording(rightHalfOfDecl); - - // Try to unprefix: - bool success; - nsAutoString unprefixedDecl; - nsresult rv = - unprefixingSvc->GenerateUnprefixedDeclaration(aPropertyName, - rightHalfOfDecl, - unprefixedDecl, &success); - if (NS_FAILED(rv) || !success) { - return false; - } - - // Attempt to parse the unprefixed declaration: - nsAutoScannerChanger scannerChanger(this, unprefixedDecl); - success = ParseDeclaration(aDeclaration, - aFlags | eParseDeclaration_FromUnprefixingSvc, - aMustCallValueAppended, aChanged, aContext); - if (success) { - // We succeeded, so we'll leave the parser pointing at the end of - // the declaration; don't restore it to the pre-recording position. - parserStateBeforeTryingToUnprefix.DoNotRestore(); - } - - return success; -} - -bool -CSSParserImpl::ParseWebkitPrefixedGradientWithService( - nsAString& aPrefixedFuncName, - nsCSSValue& aValue) -{ - MOZ_ASSERT(ShouldUseUnprefixingService(), - "Should only call if we're allowed to use unprefixing service"); - - // Record the body of the "-webkit-*gradient" function into a string. - // Note: we're already just after the opening "(". - nsAutoString prefixedFuncBody; - mScanner->StartRecording(); - bool gotCloseParen = SkipUntil(')'); - mScanner->StopRecording(prefixedFuncBody); - if (gotCloseParen) { - // Strip off trailing close-paren, so that the value we pass to the - // unprefixing service is *just* the function-body (no parens). - prefixedFuncBody.Truncate(prefixedFuncBody.Length() - 1); - } - - // NOTE: Even if we fail, we'll be leaving the parser's cursor just after - // the close of the "-webkit-*gradient(...)" expression. This is the same - // behavior that the other Parse*Gradient functions have in their failure - // cases -- they call "SkipUntil(')') before returning false. So this is - // probably what we want. - nsCOMPtr unprefixingSvc = - do_GetService(NS_CSSUNPREFIXINGSERVICE_CONTRACTID); - NS_ENSURE_TRUE(unprefixingSvc, false); - - bool success; - nsAutoString unprefixedFuncName; - nsAutoString unprefixedFuncBody; - nsresult rv = - unprefixingSvc->GenerateUnprefixedGradientValue(aPrefixedFuncName, - prefixedFuncBody, - unprefixedFuncName, - unprefixedFuncBody, - &success); - - if (NS_FAILED(rv) || !success) { - return false; - } - - // JS service thinks it successfully converted the gradient! Now let's try - // to parse the resulting string. - - // First, add a close-paren if we originally recorded one (so that what we're - // about to put into the CSS parser is a faithful representation of what it - // would've seen if it were just parsing the original input stream): - if (gotCloseParen) { - unprefixedFuncBody.Append(char16_t(')')); - } - - nsAutoScannerChanger scannerChanger(this, unprefixedFuncBody); - if (unprefixedFuncName.EqualsLiteral("linear-gradient")) { - return ParseLinearGradient(aValue, 0); - } - if (unprefixedFuncName.EqualsLiteral("radial-gradient")) { - return ParseRadialGradient(aValue, 0); - } - - NS_ERROR("CSSUnprefixingService returned an unrecognized type of " - "gradient function"); - - return false; -} - //---------------------------------------------------------------------- bool @@ -7424,19 +7259,7 @@ CSSParserImpl::ParseDeclaration(css::Declaration* aDeclaration, (aContext == eCSSContext_Page && !nsCSSProps::PropHasFlags(propID, CSS_PROPERTY_APPLIES_TO_PAGE_RULE))) { // unknown property - if (NonMozillaVendorIdentifier(propertyName)) { - if (!mInSupportsCondition && - aContext == eCSSContext_General && - !(aFlags & eParseDeclaration_FromUnprefixingSvc) && // no recursion - ShouldUseUnprefixingService()) { - if (ParsePropertyWithUnprefixingService(propertyName, - aDeclaration, aFlags, - aMustCallValueAppended, - aChanged, aContext)) { - return true; - } - } - } else { + if (!NonMozillaVendorIdentifier(propertyName)) { REPORT_UNEXPECTED_P(PEUnknownProperty, propertyName); REPORT_UNEXPECTED(PEDeclDropped); OUTPUT_ERROR(); @@ -8064,18 +7887,6 @@ CSSParserImpl::ParseVariant(nsCSSValue& aValue, } return CSSParseResult::Ok; } - - if (ShouldUseUnprefixingService() && - !gradientFlags && - StringBeginsWith(tmp, NS_LITERAL_STRING("-webkit-"))) { - // Copy 'tmp' into a string on the stack, since as soon as we - // start parsing, its backing store (in "tk") will be overwritten - nsAutoString prefixedFuncName(tmp); - if (!ParseWebkitPrefixedGradientWithService(prefixedFuncName, aValue)) { - return CSSParseResult::Error; - } - return CSSParseResult::Ok; - } } if ((aVariantMask & VARIANT_IMAGE_RECT) != 0 && eCSSToken_Function == tk->mType && @@ -12417,7 +12228,7 @@ CSSParserImpl::IsFunctionTokenValidForImageLayerImage( funcName.LowerCaseEqualsLiteral("-moz-repeating-radial-gradient") || funcName.LowerCaseEqualsLiteral("-moz-image-rect") || funcName.LowerCaseEqualsLiteral("-moz-element") || - ((sWebkitPrefixedAliasesEnabled || ShouldUseUnprefixingService()) && + (sWebkitPrefixedAliasesEnabled && (funcName.LowerCaseEqualsLiteral("-webkit-gradient") || funcName.LowerCaseEqualsLiteral("-webkit-linear-gradient") || funcName.LowerCaseEqualsLiteral("-webkit-radial-gradient") || @@ -17994,10 +17805,6 @@ nsCSSParser::Startup() "layout.css.prefixes.webkit"); Preferences::AddBoolVarCache(&sWebkitDevicePixelRatioEnabled, "layout.css.prefixes.device-pixel-ratio-webkit"); - Preferences::AddBoolVarCache(&sUnprefixingServiceEnabled, - "layout.css.unprefixing-service.enabled"); - Preferences::AddBoolVarCache(&sUnprefixingServiceGloballyWhitelisted, - "layout.css.unprefixing-service.globally-whitelisted"); Preferences::AddBoolVarCache(&sMozGradientsEnabled, "layout.css.prefixes.gradients"); Preferences::AddBoolVarCache(&sControlCharVisibility, diff --git a/layout/style/nsICSSUnprefixingService.idl b/layout/style/nsICSSUnprefixingService.idl deleted file mode 100644 index 11c3bf43f1..0000000000 --- a/layout/style/nsICSSUnprefixingService.idl +++ /dev/null @@ -1,76 +0,0 @@ -/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* interface for a service that converts certain vendor-prefixed CSS properties - to their unprefixed equivalents */ - -#include "nsISupports.idl" - -[scriptable, uuid(a5d6e2f4-d3ec-11e4-b002-782bcbaebb28)] -interface nsICSSUnprefixingService : nsISupports -{ - /** - * This function helps to convert unsupported vendor-prefixed CSS into - * supported unprefixed CSS. Given a vendor-prefixed property name and a - * value (or e.g. value + trailing junk like " !important;}"), this function - * will attempt to produce an equivalent CSS declaration that uses a - * supported unprefixed CSS property. - * - * @param aPropName - * The vendor-prefixed property name. - * - * @param aRightHalfOfDecl - * Everything after the ":" in the CSS declaration. This includes - * the property's value, along with possibly some leading whitespace - * and trailing text like "!important", and possibly a ';' and/or - * '}' (along with any other bogus text the author happens to - * include before those, which will probably make the decl invalid). - * - * @param aUnprefixedDecl[out] - * The resulting unprefixed declaration, if we return true. - * - * @return true if we were able to unprefix -- i.e. if we were able to - * convert the property to a known unprefixed equivalent, and we also - * performed any known-to-be-necessary fixup on the value, and we put - * the result in aUnprefixedDecl. - * Otherwise, this function returns false. - */ - boolean generateUnprefixedDeclaration(in AString aPropName, - in AString aRightHalfOfDecl, - out AString aUnprefixedDecl); - - /** - * @param aPrefixedFuncName - * The webkit-prefixed gradient function: either - * "-webkit-gradient", "-webkit-linear-gradient", or - * "-webkit-radial-gradient". - * - * @param aPrefixedFuncBody - * The body of the gradient function, inside (& not including) the - * parenthesis. - * - * @param aUnprefixedFuncName[out] - * The resulting unprefixed gradient function name: - * either "linear-gradient" or "radial-gradient". - * - * @param aUnprefixedFuncBody[out] - * The resulting unprefixed gradient function body, suitable for - * including in a "linear-gradient(...)" or "radial-gradient(...)" - * expression. - * - * @returns true if we were able to successfully parse aWebkitGradientStr - * and populate the outparams accordingly; false otherwise. - * - */ - boolean generateUnprefixedGradientValue(in AString aPrefixedFuncName, - in AString aPrefixedFuncBody, - out AString aUnprefixedFuncName, - out AString aUnprefixedFuncBody); -}; - -%{C++ -#define NS_CSSUNPREFIXINGSERVICE_CONTRACTID \ - "@mozilla.org/css-unprefixing-service;1" -%} diff --git a/layout/style/test/mochitest.ini b/layout/style/test/mochitest.ini index 8b36e3e1e8..2f0ab87a28 100644 --- a/layout/style/test/mochitest.ini +++ b/layout/style/test/mochitest.ini @@ -273,10 +273,6 @@ support-files = ../../reftests/fonts/markA.woff ../../reftests/fonts/markB.woff [test_units_frequency.html] [test_units_length.html] [test_units_time.html] -[test_unprefixing_service.html] -support-files = unprefixing_service_iframe.html unprefixing_service_utils.js -[test_unprefixing_service_prefs.html] -support-files = unprefixing_service_iframe.html unprefixing_service_utils.js [test_value_cloning.html] [test_value_computation.html] [test_value_storage.html] diff --git a/layout/style/test/test_unprefixing_service.html b/layout/style/test/test_unprefixing_service.html deleted file mode 100644 index c489e2ac01..0000000000 --- a/layout/style/test/test_unprefixing_service.html +++ /dev/null @@ -1,93 +0,0 @@ - - - - - - Test for Bug 1107378 - - - - - -Mozilla Bug 1107378 -
- -
-
-
-
- - diff --git a/layout/style/test/test_unprefixing_service_prefs.html b/layout/style/test/test_unprefixing_service_prefs.html deleted file mode 100644 index 329dce2a63..0000000000 --- a/layout/style/test/test_unprefixing_service_prefs.html +++ /dev/null @@ -1,132 +0,0 @@ - - - - - - Test for Bug 1132743 - - - - - -Mozilla Bug 1132743 -
- -
-
-
-
- - diff --git a/layout/style/test/unprefixing_service_iframe.html b/layout/style/test/unprefixing_service_iframe.html deleted file mode 100644 index 8edeb20dce..0000000000 --- a/layout/style/test/unprefixing_service_iframe.html +++ /dev/null @@ -1,394 +0,0 @@ - - - - - Helper file for testing CSS Unprefixing Service - - - - -
-
-
- - - - diff --git a/layout/style/test/unprefixing_service_utils.js b/layout/style/test/unprefixing_service_utils.js deleted file mode 100644 index cd17d20d08..0000000000 --- a/layout/style/test/unprefixing_service_utils.js +++ /dev/null @@ -1,87 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -// Shared data & functionality used in tests for CSS Unprefixing Service. - -// Whitelisted hosts: -// (per implementation of nsPrincipal::IsOnCSSUnprefixingWhitelist()) -var gWhitelistedHosts = [ - // test1.example.org is on the whitelist. - "test1.example.org", - // test2.example.org is on the "allow all subdomains" whitelist. - "test2.example.org", - "sub1.test2.example.org", - "sub2.test2.example.org" -]; - -// *NOT* whitelisted hosts: -var gNotWhitelistedHosts = [ - // Though test1.example.org is on the whitelist, its subdomains are not. - "sub1.test1.example.org", - // mochi.test is not on the whitelist. - "mochi.test:8888" -]; - -// Names of prefs: -const PREF_UNPREFIXING_SERVICE = - "layout.css.unprefixing-service.enabled"; -const PREF_INCLUDE_TEST_DOMAINS = - "layout.css.unprefixing-service.include-test-domains"; - -// Helper-function to make unique URLs in testHost(): -var gCounter = 0; -function getIncreasingCounter() { - return gCounter++; -} - -// This function tests a particular host in our iframe. -// @param aHost The host to be tested -// @param aExpectEnabled Should we expect unprefixing to be enabled for host? -function testHost(aHost, aExpectEnabled) { - // Build the URL: - let url = window.location.protocol; // "http:" or "https:" - url += "//"; - url += aHost; - - // Append the path-name, up to the actual filename (the final "/"): - const re = /(.*\/).*/; - url += window.location.pathname.replace(re, "$1"); - url += IFRAME_TESTFILE; - // In case this is the same URL as last time, we add "?N" for some unique N, - // to make each URL different, so that the iframe actually (re)loads: - url += "?" + getIncreasingCounter(); - // We give the URL a #suffix to indicate to the test whether it should expect - // that unprefixing is enabled or disabled: - url += (aExpectEnabled ? "#expectEnabled" : "#expectDisabled"); - - let iframe = document.getElementById("testIframe"); - iframe.contentWindow.location = url; - // The iframe will report its results back via postMessage. - // Our caller had better have set up a postMessage listener. -} - -// Register a postMessage() handler, to allow our cross-origin iframe to -// communicate back to the main page's mochitest functionality. -// The handler expects postMessage to be called with an object like: -// { type: ["is"|"ok"|"testComplete"], ... } -// The "is" and "ok" types will trigger the corresponding function to be -// called in the main page, with named arguments provided in the payload. -// The "testComplete" type will trigger the passed-in aTestCompleteCallback -// function to be invoked (e.g. to advance to the next testcase, or to finish -// the overall test, as-appropriate). -function registerPostMessageListener(aTestCompleteCallback) { - let receiveMessage = function(event) { - if (event.data.type === "is") { - is(event.data.actual, event.data.expected, event.data.desc); - } else if (event.data.type === "ok") { - ok(event.data.condition, event.data.desc); - } else if (event.data.type === "testComplete") { - aTestCompleteCallback(); - } else { - ok(false, "unrecognized data in postMessage call"); - } - }; - - window.addEventListener("message", receiveMessage, false); -} -- cgit v1.2.3