diff --git a/browser/components/contextualidentity/test/browser/browser_eme.js b/browser/components/contextualidentity/test/browser/browser_eme.js
index 25e4851d08d2..dd8cdd3f7339 100644
--- a/browser/components/contextualidentity/test/browser/browser_eme.js
+++ b/browser/components/contextualidentity/test/browser/browser_eme.js
@@ -103,7 +103,7 @@ add_task(async function test() {
let access = await content.navigator.requestMediaKeySystemAccess("org.w3.clearkey",
[{
initDataTypes: [aKeyInfo.initDataType],
- videoCapabilities: [{contentType: 'video/webm; codecs="vp9"'}],
+ videoCapabilities: [{contentType: "video/webm"}],
sessionTypes: ["persistent-license"],
persistentState: "required",
}]);
@@ -156,7 +156,7 @@ add_task(async function test() {
let access = await content.navigator.requestMediaKeySystemAccess("org.w3.clearkey",
[{
initDataTypes: [aKeyInfo.initDataType],
- videoCapabilities: [{contentType: 'video/webm; codecs="vp9"'}],
+ videoCapabilities: [{contentType: "video/webm"}],
sessionTypes: ["persistent-license"],
persistentState: "required",
}]);
diff --git a/browser/components/contextualidentity/test/browser/browser_forgetAPI_EME_forgetThisSite.js b/browser/components/contextualidentity/test/browser/browser_forgetAPI_EME_forgetThisSite.js
index 356fe0332eda..b6e948284a12 100644
--- a/browser/components/contextualidentity/test/browser/browser_forgetAPI_EME_forgetThisSite.js
+++ b/browser/components/contextualidentity/test/browser/browser_forgetAPI_EME_forgetThisSite.js
@@ -98,7 +98,7 @@ async function setupEMEKey(browser) {
let access = await content.navigator.requestMediaKeySystemAccess("org.w3.clearkey",
[{
initDataTypes: [aKeyInfo.initDataType],
- videoCapabilities: [{contentType: 'video/webm; codecs="vp9"'}],
+ videoCapabilities: [{contentType: "video/webm"}],
sessionTypes: ["persistent-license"],
persistentState: "required",
}]);
@@ -153,7 +153,7 @@ async function checkEMEKey(browser, emeSessionId) {
let access = await content.navigator.requestMediaKeySystemAccess("org.w3.clearkey",
[{
initDataTypes: [aKeyInfo.initDataType],
- videoCapabilities: [{contentType: 'video/webm; codecs="vp9"'}],
+ videoCapabilities: [{contentType: "video/webm"}],
sessionTypes: ["persistent-license"],
persistentState: "required",
}]);
diff --git a/browser/components/extensions/moz.build b/browser/components/extensions/moz.build
index 62638aa3560f..0dfbc28ec7c9 100644
--- a/browser/components/extensions/moz.build
+++ b/browser/components/extensions/moz.build
@@ -27,4 +27,12 @@ BROWSER_CHROME_MANIFESTS += [
]
MOCHITEST_MANIFESTS += ['test/mochitest/mochitest.ini']
-XPCSHELL_TESTS_MANIFESTS += ['test/xpcshell/xpcshell.ini']
+
+if CONFIG['OS_ARCH'] != 'Darwin':
+ XPCSHELL_TESTS_MANIFESTS += [
+ 'test/xpcshell/xpcshell-remote.ini',
+ ]
+
+XPCSHELL_TESTS_MANIFESTS += [
+ 'test/xpcshell/xpcshell.ini',
+]
diff --git a/browser/components/extensions/test/browser/browser-common.ini b/browser/components/extensions/test/browser/browser-common.ini
index 65f6db760aab..ff2cbbba54d1 100644
--- a/browser/components/extensions/test/browser/browser-common.ini
+++ b/browser/components/extensions/test/browser/browser-common.ini
@@ -37,6 +37,7 @@ support-files =
[browser_ext_browserAction_pageAction_icon_permissions.js]
[browser_ext_browserAction_popup.js]
[browser_ext_browserAction_popup_preload.js]
+skip-if = (os == 'win' && !debug) # bug 1352668
[browser_ext_browserAction_popup_resize.js]
[browser_ext_browserAction_simple.js]
[browser_ext_browsingData_formData.js]
diff --git a/browser/components/extensions/test/browser/head.js b/browser/components/extensions/test/browser/head.js
index 6d15b5a409a3..67605e3c3a5b 100644
--- a/browser/components/extensions/test/browser/head.js
+++ b/browser/components/extensions/test/browser/head.js
@@ -41,6 +41,7 @@ const {CustomizableUI} = Cu.import("resource:///modules/CustomizableUI.jsm", {})
if (gTestPath.includes("test-oop-extensions")) {
SpecialPowers.pushPrefEnv({set: [
["extensions.webextensions.remote", true],
+ ["layers.popups.compositing.enabled", true],
]});
// We don't want to reset this at the end of the test, so that we don't have
// to spawn a new extension child process for each test unit.
diff --git a/browser/components/extensions/test/xpcshell/head.js b/browser/components/extensions/test/xpcshell/head.js
index 6c4ce36871a6..9d9a087b3e6c 100644
--- a/browser/components/extensions/test/xpcshell/head.js
+++ b/browser/components/extensions/test/xpcshell/head.js
@@ -4,6 +4,7 @@ const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
/* exported createHttpServer, promiseConsoleOutput */
+Components.utils.import("resource://gre/modules/Services.jsm");
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "AppConstants",
@@ -24,11 +25,11 @@ XPCOMUtils.defineLazyModuleGetter(this, "NetUtil",
"resource://gre/modules/NetUtil.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Schemas",
"resource://gre/modules/Schemas.jsm");
-XPCOMUtils.defineLazyModuleGetter(this, "Services",
- "resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "TestUtils",
"resource://testing-common/TestUtils.jsm");
+Services.prefs.setBoolPref("extensions.webextensions.remote", false);
+
ExtensionTestUtils.init(this);
diff --git a/browser/components/extensions/test/xpcshell/head_remote.js b/browser/components/extensions/test/xpcshell/head_remote.js
new file mode 100644
index 000000000000..35eb498f5083
--- /dev/null
+++ b/browser/components/extensions/test/xpcshell/head_remote.js
@@ -0,0 +1,4 @@
+"use strict";
+
+Services.prefs.setBoolPref("extensions.webextensions.remote", true);
+Services.prefs.setIntPref("dom.ipc.keepProcessesAlive.extension", 1);
diff --git a/browser/components/extensions/test/xpcshell/xpcshell-common.ini b/browser/components/extensions/test/xpcshell/xpcshell-common.ini
new file mode 100644
index 000000000000..0919d94fdf4c
--- /dev/null
+++ b/browser/components/extensions/test/xpcshell/xpcshell-common.ini
@@ -0,0 +1,8 @@
+[test_ext_bookmarks.js]
+[test_ext_browsingData.js]
+[test_ext_browsingData_cookies_cache.js]
+[test_ext_browsingData_downloads.js]
+[test_ext_browsingData_passwords.js]
+[test_ext_browsingData_settings.js]
+[test_ext_history.js]
+[test_ext_geckoProfiler_control.js]
diff --git a/browser/components/extensions/test/xpcshell/xpcshell-remote.ini b/browser/components/extensions/test/xpcshell/xpcshell-remote.ini
new file mode 100644
index 000000000000..3d6343394174
--- /dev/null
+++ b/browser/components/extensions/test/xpcshell/xpcshell-remote.ini
@@ -0,0 +1,7 @@
+[DEFAULT]
+head = head.js head_remote.js
+firefox-appdir = browser
+tags = webextensions remote-webextensions
+dupe-manifest =
+
+[include:xpcshell-common.ini]
diff --git a/browser/components/extensions/test/xpcshell/xpcshell.ini b/browser/components/extensions/test/xpcshell/xpcshell.ini
index 770f7c2f323e..107e45d92a75 100644
--- a/browser/components/extensions/test/xpcshell/xpcshell.ini
+++ b/browser/components/extensions/test/xpcshell/xpcshell.ini
@@ -1,16 +1,23 @@
[DEFAULT]
head = head.js
firefox-appdir = browser
-tags = webextensions
+tags = webextensions in-process-webextensions
+dupe-manifest =
+
+# This file contains tests which are not affected by multi-process
+# configuration, or do not support out-of-process content or extensions
+# for one reason or another.
+#
+# Tests which are affected by remote content or remote extensions should
+# go in one of:
+#
+# - xpcshell-common.ini
+# For tests which should run in all configurations.
+# - xpcshell-remote.ini
+# For tests which should only run with both remote extensions and remote content.
-[test_ext_bookmarks.js]
-[test_ext_browsingData.js]
-[test_ext_browsingData_cookies_cache.js]
-[test_ext_browsingData_downloads.js]
-[test_ext_browsingData_passwords.js]
-[test_ext_browsingData_settings.js]
-[test_ext_history.js]
[test_ext_manifest_commands.js]
[test_ext_manifest_omnibox.js]
[test_ext_manifest_permissions.js]
-[test_ext_geckoProfiler_control.js]
+
+[include:xpcshell-common.ini]
diff --git a/devtools/client/inspector/boxmodel/box-model.js b/devtools/client/inspector/boxmodel/box-model.js
index 706d53bdfaa7..cc3f1e435838 100644
--- a/devtools/client/inspector/boxmodel/box-model.js
+++ b/devtools/client/inspector/boxmodel/box-model.js
@@ -127,16 +127,19 @@ BoxModel.prototype = {
}
let lastRequest = Task.spawn((function* () {
- if (!(this.isPanelVisible() &&
- this.inspector.selection.isConnected() &&
- this.inspector.selection.isElementNode())) {
+ if (!this.inspector ||
+ !this.isPanelVisible() ||
+ !this.inspector.selection.isConnected() ||
+ !this.inspector.selection.isElementNode()) {
return null;
}
let node = this.inspector.selection.nodeFront;
+
let layout = yield this.inspector.pageStyle.getLayout(node, {
autoMargins: true,
});
+
let styleEntries = yield this.inspector.pageStyle.getApplied(node, {
// We don't need styles applied to pseudo elements of the current node.
skipPseudo: true
@@ -146,12 +149,13 @@ BoxModel.prototype = {
// Update the layout properties with whether or not the element's position is
// editable with the geometry editor.
let isPositionEditable = yield this.inspector.pageStyle.isPositionEditable(node);
+
layout = Object.assign({}, layout, {
isPositionEditable,
});
- const actorCanGetOffSetParent
- = yield this.inspector.target.actorHasMethod("domwalker", "getOffsetParent");
+ const actorCanGetOffSetParent =
+ yield this.inspector.target.actorHasMethod("domwalker", "getOffsetParent");
if (actorCanGetOffSetParent) {
// Update the redux store with the latest offset parent DOM node
diff --git a/devtools/client/inspector/grids/components/GridDisplaySettings.js b/devtools/client/inspector/grids/components/GridDisplaySettings.js
index 29b3bf6b15d5..b565f02a964e 100644
--- a/devtools/client/inspector/grids/components/GridDisplaySettings.js
+++ b/devtools/client/inspector/grids/components/GridDisplaySettings.js
@@ -63,6 +63,7 @@ module.exports = createClass({
{},
dom.input(
{
+ id: "grid-setting-extend-grid-lines",
type: "checkbox",
checked: highlighterSettings.showInfiniteLines,
onChange: this.onShowInfiniteLinesCheckboxClick,
@@ -79,6 +80,7 @@ module.exports = createClass({
{},
dom.input(
{
+ id: "grid-setting-show-grid-line-numbers",
type: "checkbox",
checked: highlighterSettings.showGridLineNumbers,
onChange: this.onShowGridLineNumbersCheckboxClick,
diff --git a/devtools/client/inspector/grids/components/GridList.js b/devtools/client/inspector/grids/components/GridList.js
index 43acaebdaaf3..f997408065ec 100644
--- a/devtools/client/inspector/grids/components/GridList.js
+++ b/devtools/client/inspector/grids/components/GridList.js
@@ -48,7 +48,9 @@ module.exports = createClass({
getStr("layout.overlayGrid")
),
dom.ul(
- {},
+ {
+ id: "grid-list",
+ },
grids.map(grid => GridItem({
key: grid.id,
getSwatchColorPickerTooltip,
diff --git a/devtools/client/inspector/grids/grid-inspector.js b/devtools/client/inspector/grids/grid-inspector.js
index 4b750016d792..5ef93b7cfd11 100644
--- a/devtools/client/inspector/grids/grid-inspector.js
+++ b/devtools/client/inspector/grids/grid-inspector.js
@@ -253,13 +253,27 @@ GridInspector.prototype = {
// Get all the GridFront from the server if no gridFronts were provided.
if (!gridFronts) {
- gridFronts = yield this.layoutInspector.getAllGrids(this.walker.rootNode);
+ try {
+ gridFronts = yield this.layoutInspector.getAllGrids(this.walker.rootNode);
+ } catch (e) {
+ // This call might fail if called asynchrously after the toolbox is finished
+ // closing.
+ return;
+ }
}
let grids = [];
for (let i = 0; i < gridFronts.length; i++) {
let grid = gridFronts[i];
- let nodeFront = yield this.walker.getNodeFromActor(grid.actorID, ["containerEl"]);
+
+ let nodeFront;
+ try {
+ nodeFront = yield this.walker.getNodeFromActor(grid.actorID, ["containerEl"]);
+ } catch (e) {
+ // This call might fail if called asynchrously after the toolbox is finished
+ // closing.
+ return;
+ }
let fallbackColor = GRID_COLORS[i % GRID_COLORS.length];
let color = this.getInitialGridColor(nodeFront, fallbackColor);
@@ -300,7 +314,7 @@ GridInspector.prototype = {
* @param {Object} options
* The highlighter options used for the highlighter being shown/hidden.
*/
- onHighlighterChange(event, nodeFront, options) {
+ onHighlighterChange(event, nodeFront, options = {}) {
let highlighted = event === "grid-highlighter-shown";
let { color } = options;
diff --git a/devtools/client/inspector/grids/moz.build b/devtools/client/inspector/grids/moz.build
index 1b51bd039bfb..74ce577196a7 100644
--- a/devtools/client/inspector/grids/moz.build
+++ b/devtools/client/inspector/grids/moz.build
@@ -15,3 +15,5 @@ DevToolsModules(
'grid-inspector.js',
'types.js',
)
+
+BROWSER_CHROME_MANIFESTS += ['test/browser.ini']
diff --git a/devtools/client/inspector/grids/reducers/grids.js b/devtools/client/inspector/grids/reducers/grids.js
index 63f88a45fede..6583c653fef7 100644
--- a/devtools/client/inspector/grids/reducers/grids.js
+++ b/devtools/client/inspector/grids/reducers/grids.js
@@ -17,7 +17,7 @@ let reducers = {
[UPDATE_GRID_COLOR](grids, { nodeFront, color }) {
let newGrids = grids.map(g => {
if (g.nodeFront == nodeFront) {
- g.color = color;
+ g = Object.assign({}, g, { color });
}
return g;
diff --git a/devtools/client/inspector/grids/test/.eslintrc.js b/devtools/client/inspector/grids/test/.eslintrc.js
new file mode 100644
index 000000000000..b63e8411e3b7
--- /dev/null
+++ b/devtools/client/inspector/grids/test/.eslintrc.js
@@ -0,0 +1,9 @@
+"use strict";
+
+module.exports = {
+ // Extend from the shared list of defined globals for mochitests.
+ "extends": "../../../../.eslintrc.mochitests.js",
+ "globals": {
+ "waitUntilState": true
+ }
+};
diff --git a/devtools/client/inspector/grids/test/browser.ini b/devtools/client/inspector/grids/test/browser.ini
new file mode 100644
index 000000000000..4fa238d2ddcc
--- /dev/null
+++ b/devtools/client/inspector/grids/test/browser.ini
@@ -0,0 +1,23 @@
+[DEFAULT]
+tags = devtools
+subsuite = devtools
+support-files =
+ head.js
+ !/devtools/client/commandline/test/helpers.js
+ !/devtools/client/framework/test/shared-head.js
+ !/devtools/client/inspector/test/head.js
+ !/devtools/client/inspector/test/shared-head.js
+ !/devtools/client/shared/test/test-actor.js
+ !/devtools/client/shared/test/test-actor-registry.js
+ !/devtools/client/framework/test/shared-redux-head.js
+
+[browser_grids_display-setting-extend-grid-lines.js]
+[browser_grids_display-setting-show-grid-line-numbers.js]
+[browser_grids_grid-list-color-picker-on-ESC.js]
+[browser_grids_grid-list-color-picker-on-RETURN.js]
+[browser_grids_grid-list-element-rep.js]
+[browser_grids_grid-list-no-grids.js]
+[browser_grids_grid-list-on-mutation-element-added.js]
+[browser_grids_grid-list-on-mutation-element-removed.js]
+[browser_grids_grid-list-toggle-multiple-grids.js]
+[browser_grids_grid-list-toggle-single-grid.js]
diff --git a/devtools/client/inspector/grids/test/browser_grids_display-setting-extend-grid-lines.js b/devtools/client/inspector/grids/test/browser_grids_display-setting-extend-grid-lines.js
new file mode 100644
index 000000000000..e6b68647dcfb
--- /dev/null
+++ b/devtools/client/inspector/grids/test/browser_grids_display-setting-extend-grid-lines.js
@@ -0,0 +1,51 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// Tests that the 'Extend grid lines infinitely' grid highlighter setting will update
+// the redux store and pref setting.
+
+const TEST_URI = `
+
+
+`;
+
+const SHOW_INFINITE_LINES_PREF = "devtools.gridinspector.showInfiniteLines";
+
+add_task(function* () {
+ yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
+ let { inspector, gridInspector } = yield openLayoutView();
+ let { document: doc } = gridInspector;
+ let { store } = inspector;
+
+ yield selectNode("#grid", inspector);
+ let checkbox = doc.getElementById("grid-setting-extend-grid-lines");
+
+ ok(!Services.prefs.getBoolPref(SHOW_INFINITE_LINES_PREF),
+ "'Extend grid lines infinitely' is pref off by default.");
+
+ info("Toggling ON the 'Extend grid lines infinitely' setting.");
+ let onCheckboxChange = waitUntilState(store, state =>
+ state.highlighterSettings.showInfiniteLines);
+ checkbox.click();
+ yield onCheckboxChange;
+
+ info("Toggling OFF the 'Extend grid lines infinitely' setting.");
+ onCheckboxChange = waitUntilState(store, state =>
+ !state.highlighterSettings.showInfiniteLines);
+ checkbox.click();
+ yield onCheckboxChange;
+
+ ok(!Services.prefs.getBoolPref(SHOW_INFINITE_LINES_PREF),
+ "'Extend grid lines infinitely' is pref off.");
+
+ Services.prefs.clearUserPref(SHOW_INFINITE_LINES_PREF);
+});
diff --git a/devtools/client/inspector/grids/test/browser_grids_display-setting-show-grid-line-numbers.js b/devtools/client/inspector/grids/test/browser_grids_display-setting-show-grid-line-numbers.js
new file mode 100644
index 000000000000..b5c9a5a50af7
--- /dev/null
+++ b/devtools/client/inspector/grids/test/browser_grids_display-setting-show-grid-line-numbers.js
@@ -0,0 +1,55 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// Tests that the 'Display numbers on lines' grid highlighter setting will update
+// the redux store and pref setting.
+
+const TEST_URI = `
+
+
+`;
+
+const SHOW_GRID_LINE_NUMBERS = "devtools.gridinspector.showGridLineNumbers";
+
+add_task(function* () {
+ yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
+ let { inspector, gridInspector } = yield openLayoutView();
+ let { document: doc } = gridInspector;
+ let { store } = inspector;
+
+ yield selectNode("#grid", inspector);
+ let checkbox = doc.getElementById("grid-setting-show-grid-line-numbers");
+
+ info("Checking the initial state of the CSS grid highlighter setting.");
+ ok(!Services.prefs.getBoolPref(SHOW_GRID_LINE_NUMBERS),
+ "'Display numbers on lines' is pref off by default.");
+
+ info("Toggling ON the 'Display numbers on lines' setting.");
+ let onCheckboxChange = waitUntilState(store, state =>
+ state.highlighterSettings.showGridLineNumbers);
+ checkbox.click();
+ yield onCheckboxChange;
+
+ ok(Services.prefs.getBoolPref(SHOW_GRID_LINE_NUMBERS),
+ "'Display numbers on lines' is pref on.");
+
+ info("Toggling OFF the 'Display numbers on lines' setting.");
+ onCheckboxChange = waitUntilState(store, state =>
+ !state.highlighterSettings.showGridLineNumbers);
+ checkbox.click();
+ yield onCheckboxChange;
+
+ ok(!Services.prefs.getBoolPref(SHOW_GRID_LINE_NUMBERS),
+ "'Display numbers on lines' is pref off.");
+
+ Services.prefs.clearUserPref(SHOW_GRID_LINE_NUMBERS);
+});
diff --git a/devtools/client/inspector/grids/test/browser_grids_grid-list-color-picker-on-ESC.js b/devtools/client/inspector/grids/test/browser_grids_grid-list-color-picker-on-ESC.js
new file mode 100644
index 000000000000..c182c6d1cd8e
--- /dev/null
+++ b/devtools/client/inspector/grids/test/browser_grids_grid-list-color-picker-on-ESC.js
@@ -0,0 +1,58 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// Tests that the grid item's color change in the colorpicker is reverted when ESCAPE is
+// pressed.
+
+const TEST_URI = `
+
+
+`;
+
+add_task(function* () {
+ yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
+ let { inspector, gridInspector } = yield openLayoutView();
+ let { document: doc } = gridInspector;
+ let { store } = inspector;
+ let cPicker = gridInspector.getSwatchColorPickerTooltip();
+ let spectrum = cPicker.spectrum;
+ let swatch = doc.querySelector(".grid-color-swatch");
+
+ info("Checking the initial state of the Grid Inspector.");
+ is(swatch.style.backgroundColor, "rgb(75, 0, 130)",
+ "The color swatch's background is correct.");
+ is(store.getState().grids[0].color, "#4B0082", "The grid color state is correct.");
+
+ info("Scrolling into view of the #grid color swatch.");
+ swatch.scrollIntoView();
+
+ info("Opening the color picker by clicking on the #grid color swatch.");
+ let onColorPickerReady = cPicker.once("ready");
+ swatch.click();
+ yield onColorPickerReady;
+
+ yield simulateColorPickerChange(cPicker, [0, 255, 0, .5]);
+
+ is(swatch.style.backgroundColor, "rgba(0, 255, 0, 0.5)",
+ "The color swatch's background was updated.");
+
+ info("Pressing ESCAPE to close the tooltip.");
+ let onGridColorUpdate = waitUntilState(store, state =>
+ state.grids[0].color === "#4B0082");
+ let onColorPickerHidden = cPicker.tooltip.once("hidden");
+ focusAndSendKey(spectrum.element.ownerDocument.defaultView, "ESCAPE");
+ yield onColorPickerHidden;
+ yield onGridColorUpdate;
+
+ is(swatch.style.backgroundColor, "rgb(75, 0, 130)",
+ "The color swatch's background was reverted after ESCAPE.");
+});
diff --git a/devtools/client/inspector/grids/test/browser_grids_grid-list-color-picker-on-RETURN.js b/devtools/client/inspector/grids/test/browser_grids_grid-list-color-picker-on-RETURN.js
new file mode 100644
index 000000000000..e89976617e8e
--- /dev/null
+++ b/devtools/client/inspector/grids/test/browser_grids_grid-list-color-picker-on-RETURN.js
@@ -0,0 +1,58 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// Tests that the grid item's color change in the colorpicker is committed when RETURN is
+// pressed.
+
+const TEST_URI = `
+
+
+`;
+
+add_task(function* () {
+ yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
+ let { inspector, gridInspector } = yield openLayoutView();
+ let { document: doc } = gridInspector;
+ let { store } = inspector;
+ let cPicker = gridInspector.getSwatchColorPickerTooltip();
+ let spectrum = cPicker.spectrum;
+ let swatch = doc.querySelector(".grid-color-swatch");
+
+ info("Checking the initial state of the Grid Inspector.");
+ is(swatch.style.backgroundColor, "rgb(75, 0, 130)",
+ "The color swatch's background is correct.");
+ is(store.getState().grids[0].color, "#4B0082", "The grid color state is correct.");
+
+ info("Scrolling into view of the #grid color swatch.");
+ swatch.scrollIntoView();
+
+ info("Opening the color picker by clicking on the #grid color swatch.");
+ let onColorPickerReady = cPicker.once("ready");
+ swatch.click();
+ yield onColorPickerReady;
+
+ yield simulateColorPickerChange(cPicker, [0, 255, 0, .5]);
+
+ is(swatch.style.backgroundColor, "rgba(0, 255, 0, 0.5)",
+ "The color swatch's background was updated.");
+
+ info("Pressing RETURN to commit the color change.");
+ let onGridColorUpdate = waitUntilState(store, state =>
+ state.grids[0].color === "#00FF0080");
+ let onColorPickerHidden = cPicker.tooltip.once("hidden");
+ focusAndSendKey(spectrum.element.ownerDocument.defaultView, "RETURN");
+ yield onColorPickerHidden;
+ yield onGridColorUpdate;
+
+ is(swatch.style.backgroundColor, "rgba(0, 255, 0, 0.5)",
+ "The color swatch's background was kept after RETURN.");
+});
diff --git a/devtools/client/inspector/grids/test/browser_grids_grid-list-element-rep.js b/devtools/client/inspector/grids/test/browser_grids_grid-list-element-rep.js
new file mode 100644
index 000000000000..f6b3a8d3b161
--- /dev/null
+++ b/devtools/client/inspector/grids/test/browser_grids_grid-list-element-rep.js
@@ -0,0 +1,49 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// Tests that the grid item's element rep will display the box model higlighter on hover
+// and select the node on click.
+
+const TEST_URI = `
+
+
+`;
+
+add_task(function* () {
+ yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
+ let { inspector, gridInspector, toolbox } = yield openLayoutView();
+ let { document: doc } = gridInspector;
+ let { store } = inspector;
+
+ let gridList = doc.querySelector("#grid-list");
+ let elementRep = gridList.children[0].querySelector(".open-inspector");
+ info("Scrolling into the view the #grid element node rep.");
+ elementRep.scrollIntoView();
+
+ info("Listen to node-highlight event and mouse over the widget");
+ let onHighlight = toolbox.once("node-highlight");
+ EventUtils.synthesizeMouse(elementRep, 10, 5, {type: "mouseover"}, doc.defaultView);
+ let nodeFront = yield onHighlight;
+
+ ok(nodeFront, "nodeFront was returned from highlighting the node.");
+ is(nodeFront.tagName, "DIV", "The highlighted node has the correct tagName.");
+ is(nodeFront.attributes[0].name, "id",
+ "The highlighted node has the correct attributes.");
+ is(nodeFront.attributes[0].value, "grid", "The highlighted node has the correct id.");
+
+ let onSelection = inspector.selection.once("new-node-front");
+ EventUtils.sendMouseEvent({type: "click"}, elementRep, doc.defaultView);
+ yield onSelection;
+
+ is(inspector.selection.nodeFront, store.getState().grids[0].nodeFront,
+ "The selected node is the one stored on the grid item's state.");
+});
diff --git a/devtools/client/inspector/grids/test/browser_grids_grid-list-no-grids.js b/devtools/client/inspector/grids/test/browser_grids_grid-list-no-grids.js
new file mode 100644
index 000000000000..73ec6ddac545
--- /dev/null
+++ b/devtools/client/inspector/grids/test/browser_grids_grid-list-no-grids.js
@@ -0,0 +1,34 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// Tests that no grid list items and a "no grids available" message is displayed when
+// there are no grid containers on the page.
+
+const TEST_URI = `
+
+
+`;
+
+add_task(function* () {
+ yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
+ let { inspector, gridInspector } = yield openLayoutView();
+ let { document: doc } = gridInspector;
+ let { highlighters } = inspector;
+
+ yield selectNode("#grid", inspector);
+ let noGridList = doc.querySelector(".layout-no-grids");
+ let gridList = doc.querySelector("#grid-list");
+
+ info("Checking the initial state of the Grid Inspector.");
+ ok(noGridList, "The message no grid containers is displayed.");
+ ok(!gridList, "No grid containers are listed.");
+ ok(!highlighters.highlighters[HIGHLIGHTER_TYPE],
+ "No CSS grid highlighter exists in the highlighters overlay.");
+ ok(!highlighters.gridHighlighterShown, "No CSS grid highlighter is shown.");
+});
diff --git a/devtools/client/inspector/grids/test/browser_grids_grid-list-on-mutation-element-added.js b/devtools/client/inspector/grids/test/browser_grids_grid-list-on-mutation-element-added.js
new file mode 100644
index 000000000000..b1429398939a
--- /dev/null
+++ b/devtools/client/inspector/grids/test/browser_grids_grid-list-on-mutation-element-added.js
@@ -0,0 +1,93 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// Tests that the grid list updates when a new grid container is added to the page.
+
+const TEST_URI = `
+
+
+
+`;
+
+add_task(function* () {
+ yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
+ let { inspector, gridInspector, testActor } = yield openLayoutView();
+ let { document: doc } = gridInspector;
+ let { highlighters, store } = inspector;
+
+ yield selectNode("#grid", inspector);
+ let gridList = doc.querySelector("#grid-list");
+ let checkbox1 = gridList.children[0].querySelector("input");
+
+ info("Checking the initial state of the Grid Inspector.");
+ is(gridList.childNodes.length, 1, "One grid container is listed.");
+ ok(!highlighters.highlighters[HIGHLIGHTER_TYPE],
+ "No CSS grid highlighter exists in the highlighters overlay.");
+ ok(!highlighters.gridHighlighterShown, "No CSS grid highlighter is shown.");
+
+ info("Toggling ON the CSS grid highlighter from the layout panel.");
+ let onHighlighterShown = highlighters.once("grid-highlighter-shown");
+ checkbox1.click();
+ yield onHighlighterShown;
+
+ info("Checking the CSS grid highlighter is created.");
+ ok(highlighters.highlighters[HIGHLIGHTER_TYPE],
+ "CSS grid highlighter is created in the highlighters overlay.");
+ ok(highlighters.gridHighlighterShown, "CSS grid highlighter is shown.");
+
+ info("Adding the #grid2 container in the content page.");
+ let onGridListUpdate = waitUntilState(store, state =>
+ state.grids.length == 2 &&
+ state.grids[0].highlighted &&
+ !state.grids[1].highlighted);
+ testActor.eval(`
+ content.document.getElementById("grid2").classList.add("grid");
+ `);
+ yield onGridListUpdate;
+
+ info("Checking the new Grid Inspector state.");
+ is(gridList.childNodes.length, 2, "Two grid containers are listed.");
+ ok(highlighters.highlighters[HIGHLIGHTER_TYPE],
+ "CSS grid highlighter is created in the highlighters overlay.");
+ ok(highlighters.gridHighlighterShown, "CSS grid highlighter is shown.");
+
+ let checkbox2 = gridList.children[1].querySelector("input");
+
+ info("Toggling ON the CSS grid highlighter for #grid2.");
+ onHighlighterShown = highlighters.once("grid-highlighter-shown");
+ let onCheckboxChange = waitUntilState(store, state =>
+ state.grids.length == 2 &&
+ !state.grids[0].highlighted &&
+ state.grids[1].highlighted);
+ checkbox2.click();
+ yield onHighlighterShown;
+ yield onCheckboxChange;
+
+ info("Checking the CSS grid highlighter is still shown.");
+ ok(highlighters.gridHighlighterShown, "CSS grid highlighter is shown.");
+
+ info("Toggling OFF the CSS grid highlighter from the layout panel.");
+ let onHighlighterHidden = highlighters.once("grid-highlighter-hidden");
+ onCheckboxChange = waitUntilState(store, state =>
+ state.grids.length == 2 &&
+ !state.grids[0].highlighted &&
+ !state.grids[1].highlighted);
+ checkbox2.click();
+ yield onHighlighterHidden;
+ yield onCheckboxChange;
+
+ info("Checking the CSS grid highlighter is not shown.");
+ ok(!highlighters.gridHighlighterShown, "No CSS grid highlighter is shown.");
+});
diff --git a/devtools/client/inspector/grids/test/browser_grids_grid-list-on-mutation-element-removed.js b/devtools/client/inspector/grids/test/browser_grids_grid-list-on-mutation-element-removed.js
new file mode 100644
index 000000000000..99cfaaf9ecaa
--- /dev/null
+++ b/devtools/client/inspector/grids/test/browser_grids_grid-list-on-mutation-element-removed.js
@@ -0,0 +1,63 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// Tests that the grid item is removed from the grid list when the grid container is
+// removed from the page.
+
+const TEST_URI = `
+
+
+`;
+
+add_task(function* () {
+ yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
+ let { inspector, gridInspector, testActor } = yield openLayoutView();
+ let { document: doc } = gridInspector;
+ let { highlighters, store } = inspector;
+
+ yield selectNode("#grid", inspector);
+ let gridList = doc.querySelector("#grid-list");
+ let checkbox = gridList.children[0].querySelector("input");
+
+ info("Checking the initial state of the Grid Inspector.");
+ is(gridList.childNodes.length, 1, "One grid container is listed.");
+ ok(!highlighters.highlighters[HIGHLIGHTER_TYPE],
+ "No CSS grid highlighter exists in the highlighters overlay.");
+ ok(!highlighters.gridHighlighterShown, "No CSS grid highlighter is shown.");
+
+ info("Toggling ON the CSS grid highlighter from the layout panel.");
+ let onHighlighterShown = highlighters.once("grid-highlighter-shown");
+ let onCheckboxChange = waitUntilState(store, state =>
+ state.grids.length == 1 && state.grids[0].highlighted);
+ checkbox.click();
+ yield onHighlighterShown;
+ yield onCheckboxChange;
+
+ info("Checking the CSS grid highlighter is created.");
+ ok(highlighters.highlighters[HIGHLIGHTER_TYPE],
+ "CSS grid highlighter is created in the highlighters overlay.");
+ ok(highlighters.gridHighlighterShown, "CSS grid highlighter is shown.");
+
+ info("Removing the #grid container in the content page.");
+ let onHighlighterHidden = highlighters.once("grid-highlighter-hidden");
+ onCheckboxChange = waitUntilState(store, state => state.grids.length == 0);
+ testActor.eval(`
+ content.document.getElementById("grid").remove();
+ `);
+ yield onHighlighterHidden;
+ yield onCheckboxChange;
+
+ info("Checking the CSS grid highlighter is not shown.");
+ ok(!highlighters.gridHighlighterShown, "No CSS grid highlighter is shown.");
+ let noGridList = doc.querySelector(".layout-no-grids");
+ ok(noGridList, "The message no grid containers is displayed.");
+});
diff --git a/devtools/client/inspector/grids/test/browser_grids_grid-list-toggle-multiple-grids.js b/devtools/client/inspector/grids/test/browser_grids_grid-list-toggle-multiple-grids.js
new file mode 100644
index 000000000000..b2e21d010e6b
--- /dev/null
+++ b/devtools/client/inspector/grids/test/browser_grids_grid-list-toggle-multiple-grids.js
@@ -0,0 +1,84 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// Test toggling the grid highlighter in the grid inspector panel with multiple grids in
+// the page.
+
+const TEST_URI = `
+
+
+
+`;
+
+add_task(function* () {
+ yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
+ let { inspector, gridInspector } = yield openLayoutView();
+ let { document: doc } = gridInspector;
+ let { highlighters, store } = inspector;
+
+ yield selectNode("#grid1", inspector);
+ let gridList = doc.querySelector("#grid-list");
+ let checkbox1 = gridList.children[0].querySelector("input");
+ let checkbox2 = gridList.children[1].querySelector("input");
+
+ info("Checking the initial state of the Grid Inspector.");
+ is(gridList.childNodes.length, 2, "2 grid containers are listed.");
+ ok(!checkbox1.checked, `Grid item ${checkbox1.value} is unchecked in the grid list.`);
+ ok(!checkbox2.checked, `Grid item ${checkbox2.value} is unchecked in the grid list.`);
+ ok(!highlighters.highlighters[HIGHLIGHTER_TYPE],
+ "No CSS grid highlighter exists in the highlighters overlay.");
+ ok(!highlighters.gridHighlighterShown, "No CSS grid highlighter is shown.");
+
+ info("Toggling ON the CSS grid highlighter for #grid1.");
+ let onHighlighterShown = highlighters.once("grid-highlighter-shown");
+ let onCheckboxChange = waitUntilState(store, state =>
+ state.grids.length == 2 &&
+ state.grids[0].highlighted &&
+ !state.grids[1].highlighted);
+ checkbox1.click();
+ yield onHighlighterShown;
+ yield onCheckboxChange;
+
+ info("Checking the CSS grid highlighter is created.");
+ ok(highlighters.highlighters[HIGHLIGHTER_TYPE],
+ "CSS grid highlighter is created in the highlighters overlay.");
+ ok(highlighters.gridHighlighterShown, "CSS grid highlighter is shown.");
+
+ info("Toggling ON the CSS grid highlighter for #grid2.");
+ onHighlighterShown = highlighters.once("grid-highlighter-shown");
+ onCheckboxChange = waitUntilState(store, state =>
+ state.grids.length == 2 &&
+ !state.grids[0].highlighted &&
+ state.grids[1].highlighted);
+ checkbox2.click();
+ yield onHighlighterShown;
+ yield onCheckboxChange;
+
+ info("Checking the CSS grid highlighter is still shown.");
+ ok(highlighters.gridHighlighterShown, "CSS grid highlighter is shown.");
+
+ info("Toggling OFF the CSS grid highlighter from the layout panel.");
+ let onHighlighterHidden = highlighters.once("grid-highlighter-hidden");
+ onCheckboxChange = waitUntilState(store, state =>
+ state.grids.length == 2 &&
+ !state.grids[0].highlighted &&
+ !state.grids[1].highlighted);
+ checkbox2.click();
+ yield onHighlighterHidden;
+ yield onCheckboxChange;
+
+ info("Checking the CSS grid highlighter is not shown.");
+ ok(!highlighters.gridHighlighterShown, "No CSS grid highlighter is shown.");
+});
diff --git a/devtools/client/inspector/grids/test/browser_grids_grid-list-toggle-single-grid.js b/devtools/client/inspector/grids/test/browser_grids_grid-list-toggle-single-grid.js
new file mode 100644
index 000000000000..f7653a34bffe
--- /dev/null
+++ b/devtools/client/inspector/grids/test/browser_grids_grid-list-toggle-single-grid.js
@@ -0,0 +1,62 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// Tests toggling ON/OFF the grid highlighter from the grid ispector panel.
+
+const TEST_URI = `
+
+
+`;
+
+add_task(function* () {
+ yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
+ let { gridInspector, inspector } = yield openLayoutView();
+ let { document: doc } = gridInspector;
+ let { highlighters, store } = inspector;
+
+ yield selectNode("#grid", inspector);
+ let gridList = doc.querySelector("#grid-list");
+ let checkbox = gridList.children[0].querySelector("input");
+
+ info("Checking the initial state of the Grid Inspector.");
+ is(gridList.childNodes.length, 1, "One grid container is listed.");
+ ok(!checkbox.checked, `Grid item ${checkbox.value} is unchecked in the grid list.`);
+ ok(!highlighters.highlighters[HIGHLIGHTER_TYPE],
+ "No CSS grid highlighter exists in the highlighters overlay.");
+ ok(!highlighters.gridHighlighterShown, "No CSS grid highlighter is shown.");
+
+ info("Toggling ON the CSS grid highlighter from the layout panel.");
+ let onHighlighterShown = highlighters.once("grid-highlighter-shown");
+ let onCheckboxChange = waitUntilState(store, state =>
+ state.grids.length == 1 &&
+ state.grids[0].highlighted);
+ checkbox.click();
+ yield onHighlighterShown;
+ yield onCheckboxChange;
+
+ info("Checking the CSS grid highlighter is created.");
+ ok(highlighters.highlighters[HIGHLIGHTER_TYPE],
+ "CSS grid highlighter is created in the highlighters overlay.");
+ ok(highlighters.gridHighlighterShown, "CSS grid highlighter is shown.");
+
+ info("Toggling OFF the CSS grid highlighter from the layout panel.");
+ let onHighlighterHidden = highlighters.once("grid-highlighter-hidden");
+ onCheckboxChange = waitUntilState(store, state =>
+ state.grids.length == 1 &&
+ !state.grids[0].highlighted);
+ checkbox.click();
+ yield onHighlighterHidden;
+ yield onCheckboxChange;
+
+ info("Checking the CSS grid highlighter is not shown.");
+ ok(!highlighters.gridHighlighterShown, "No CSS grid highlighter is shown.");
+});
diff --git a/devtools/client/inspector/grids/test/head.js b/devtools/client/inspector/grids/test/head.js
new file mode 100644
index 000000000000..a00ae91fb2dd
--- /dev/null
+++ b/devtools/client/inspector/grids/test/head.js
@@ -0,0 +1,74 @@
+/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+/* eslint no-unused-vars: [2, {"vars": "local"}] */
+/* import-globals-from ../../../framework/test/shared-head.js */
+/* import-globals-from ../../test/head.js */
+"use strict";
+
+// Import the inspector's head.js first (which itself imports shared-head.js).
+Services.scriptloader.loadSubScript(
+ "chrome://mochitests/content/browser/devtools/client/inspector/test/head.js",
+ this);
+
+// Load the shared Redux helpers into this compartment.
+Services.scriptloader.loadSubScript(
+ "chrome://mochitests/content/browser/devtools/client/framework/test/shared-redux-head.js",
+ this);
+
+Services.prefs.setBoolPref("devtools.layoutview.enabled", true);
+Services.prefs.setIntPref("devtools.toolbox.footer.height", 350);
+registerCleanupFunction(() => {
+ Services.prefs.clearUserPref("devtools.layoutview.enabled");
+ Services.prefs.clearUserPref("devtools.toolbox.footer.height");
+});
+
+const HIGHLIGHTER_TYPE = "CssGridHighlighter";
+
+/**
+ * Open the toolbox, with the inspector tool visible, and the layout view
+ * sidebar tab selected to display the box model view with properties.
+ *
+ * @return {Promise} a promise that resolves when the inspector is ready and the box model
+ * view is visible and ready.
+ */
+function openLayoutView() {
+ return openInspectorSidebarTab("layoutview").then(data => {
+ // The actual highligher show/hide methods are mocked in box model tests.
+ // The highlighter is tested in devtools/inspector/test.
+ function mockHighlighter({highlighter}) {
+ highlighter.showBoxModel = function () {
+ return promise.resolve();
+ };
+ highlighter.hideBoxModel = function () {
+ return promise.resolve();
+ };
+ }
+ mockHighlighter(data.toolbox);
+
+ return {
+ toolbox: data.toolbox,
+ inspector: data.inspector,
+ gridInspector: data.inspector.gridInspector,
+ testActor: data.testActor
+ };
+ });
+}
+
+/**
+ * Simulate a color change in a given color picker tooltip.
+ *
+ * @param {Spectrum|ColorWidget} colorPicker
+ * The color picker widget.
+ * @param {Array} newRgba
+ * Array of the new rgba values to be set in the color widget.
+ */
+var simulateColorPickerChange = Task.async(function* (colorPicker, newRgba) {
+ info("Getting the spectrum colorpicker object");
+ let spectrum = yield colorPicker.spectrum;
+ info("Setting the new color");
+ spectrum.rgb = newRgba;
+ info("Applying the change");
+ spectrum.updateUI();
+ spectrum.onChange();
+});
diff --git a/devtools/client/inspector/rules/test/head.js b/devtools/client/inspector/rules/test/head.js
index 55f7b71e88a2..0d8f9f88a937 100644
--- a/devtools/client/inspector/rules/test/head.js
+++ b/devtools/client/inspector/rules/test/head.js
@@ -497,16 +497,6 @@ function* clickSelectorIcon(icon, view) {
yield onToggled;
}
-/**
- * Make sure window is properly focused before sending a key event.
- * @param {Window} win
- * @param {Event} key
- */
-function focusAndSendKey(win, key) {
- win.document.documentElement.focus();
- EventUtils.sendKey(key, win);
-}
-
/**
* Toggle one of the checkboxes inside the class-panel. Resolved after the DOM mutation
* has been recorded.
diff --git a/devtools/client/inspector/shared/highlighters-overlay.js b/devtools/client/inspector/shared/highlighters-overlay.js
index 39add94725eb..d975d23f7ba1 100644
--- a/devtools/client/inspector/shared/highlighters-overlay.js
+++ b/devtools/client/inspector/shared/highlighters-overlay.js
@@ -6,7 +6,6 @@
"use strict";
-const promise = require("promise");
const {Task} = require("devtools/shared/task");
const EventEmitter = require("devtools/shared/event-emitter");
const { VIEW_NODE_VALUE_TYPE } = require("devtools/client/inspector/shared/node-types");
@@ -267,18 +266,26 @@ HighlightersOverlay.prototype = {
* The highlighter type. One of this.highlighters.
* @return {Promise} that resolves to the highlighter
*/
- _getHighlighter: function (type) {
+ _getHighlighter: Task.async(function* (type) {
let utils = this.highlighterUtils;
if (this.highlighters[type]) {
- return promise.resolve(this.highlighters[type]);
+ return this.highlighters[type];
}
- return utils.getHighlighterByType(type).then(highlighter => {
- this.highlighters[type] = highlighter;
- return highlighter;
- });
- },
+ let highlighter;
+
+ try {
+ highlighter = yield utils.getHighlighterByType(type);
+ } catch (e) {}
+
+ if (!highlighter) {
+ return null;
+ }
+
+ this.highlighters[type] = highlighter;
+ return highlighter;
+ }),
_handleRejection: function (error) {
if (!this.destroyed) {
diff --git a/devtools/client/inspector/test/head.js b/devtools/client/inspector/test/head.js
index 2eb6f44ababc..c5cd9a8fd046 100644
--- a/devtools/client/inspector/test/head.js
+++ b/devtools/client/inspector/test/head.js
@@ -643,6 +643,19 @@ function synthesizeKeys(input, win) {
}
}
+/**
+ * Make sure window is properly focused before sending a key event.
+ *
+ * @param {Window} win
+ * The window containing the panel
+ * @param {String} key
+ * The string value to input
+ */
+function focusAndSendKey(win, key) {
+ win.document.documentElement.focus();
+ EventUtils.sendKey(key, win);
+}
+
/**
* Given a Tooltip instance, fake a mouse event on the `target` DOM Element
* and assert that the `tooltip` is correctly displayed.
diff --git a/dom/animation/test/chrome/test_restyles.html b/dom/animation/test/chrome/test_restyles.html
index de94f3bb6cb6..370e8db04dd2 100644
--- a/dom/animation/test/chrome/test_restyles.html
+++ b/dom/animation/test/chrome/test_restyles.html
@@ -62,6 +62,7 @@ function ensureElementRemoval(aElement) {
});
}
+SimpleTest.expectAssertions(0, 1); // bug 1332970
SimpleTest.waitForExplicitFinish();
var omtaEnabled = isOMTAEnabled();
diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp
index 86b6ed96ec79..2b373a075dea 100644
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -10010,9 +10010,9 @@ nsIDocument::RegisterPendingLinkUpdate(Link* aLink)
if (!mHasLinksToUpdateRunnable) {
nsCOMPtr event =
NewRunnableMethod(this, &nsIDocument::FlushPendingLinkUpdatesFromRunnable);
+ // Do this work in a second in the worst case.
nsresult rv =
- Dispatch("nsIDocument::FlushPendingLinkUpdatesFromRunnable",
- TaskCategory::Other, event.forget());
+ NS_IdleDispatchToCurrentThread(event.forget(), 1000);
if (NS_FAILED(rv)) {
// If during shutdown posting a runnable doesn't succeed, we probably
// don't need to update link states.
diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp
index 1f3249b8f0c2..1c5839f92d17 100644
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -867,7 +867,11 @@ nsGlobalWindow::ExecuteIdleRequest(TimeStamp aDeadline)
mIdleRequestExecutor->MaybeUpdateIdlePeriodLimit();
nsresult result = RunIdleRequest(request, deadline, false);
- mIdleRequestExecutor->MaybeDispatch();
+ // Running the idle callback could've suspended the window, in which
+ // case mIdleRequestExecutor will be null.
+ if (mIdleRequestExecutor) {
+ mIdleRequestExecutor->MaybeDispatch();
+ }
return result;
}
diff --git a/dom/base/nsJSUtils.cpp b/dom/base/nsJSUtils.cpp
index 424d97340f5f..d11bbf6d2e4b 100644
--- a/dom/base/nsJSUtils.cpp
+++ b/dom/base/nsJSUtils.cpp
@@ -146,6 +146,7 @@ nsJSUtils::ExecutionContext::ExecutionContext(JSContext* aCx,
, mRv(NS_OK)
, mSkip(false)
, mCoerceToString(false)
+ , mEncodeBytecode(false)
#ifdef DEBUG
, mWantsReturnValue(false)
, mExpectScopeChain(false)
@@ -204,7 +205,19 @@ nsJSUtils::ExecutionContext::JoinAndExec(void **aOffThreadToken,
MOZ_ASSERT(!mExpectScopeChain);
aScript.set(JS::FinishOffThreadScript(mCx, *aOffThreadToken));
*aOffThreadToken = nullptr; // Mark the token as having been finished.
- if (!aScript || !JS_ExecuteScript(mCx, mScopeChain, aScript)) {
+ if (!aScript) {
+ mSkip = true;
+ mRv = EvaluationExceptionToNSResult(mCx);
+ return mRv;
+ }
+
+ if (mEncodeBytecode && !StartIncrementalEncoding(mCx, aScript)) {
+ mSkip = true;
+ mRv = EvaluationExceptionToNSResult(mCx);
+ return mRv;
+ }
+
+ if (!JS_ExecuteScript(mCx, mScopeChain, aScript)) {
mSkip = true;
mRv = EvaluationExceptionToNSResult(mCx);
return mRv;
@@ -215,7 +228,8 @@ nsJSUtils::ExecutionContext::JoinAndExec(void **aOffThreadToken,
nsresult
nsJSUtils::ExecutionContext::CompileAndExec(JS::CompileOptions& aCompileOptions,
- JS::SourceBufferHolder& aSrcBuf)
+ JS::SourceBufferHolder& aSrcBuf,
+ JS::MutableHandle aScript)
{
if (mSkip) {
return mRv;
@@ -228,8 +242,29 @@ nsJSUtils::ExecutionContext::CompileAndExec(JS::CompileOptions& aCompileOptions,
#ifdef DEBUG
mWantsReturnValue = !aCompileOptions.noScriptRval;
#endif
+
+ bool compiled = true;
+ if (mScopeChain.length() == 0) {
+ compiled = JS::Compile(mCx, aCompileOptions, aSrcBuf, aScript);
+ } else {
+ compiled = JS::CompileForNonSyntacticScope(mCx, aCompileOptions, aSrcBuf, aScript);
+ }
+
+ MOZ_ASSERT_IF(compiled, aScript);
+ if (!compiled) {
+ mSkip = true;
+ mRv = EvaluationExceptionToNSResult(mCx);
+ return mRv;
+ }
+
+ if (mEncodeBytecode && !StartIncrementalEncoding(mCx, aScript)) {
+ mSkip = true;
+ mRv = EvaluationExceptionToNSResult(mCx);
+ return mRv;
+ }
+
MOZ_ASSERT(!mCoerceToString || mWantsReturnValue);
- if (!JS::Evaluate(mCx, mScopeChain, aCompileOptions, aSrcBuf, &mRetValue)) {
+ if (!JS_ExecuteScript(mCx, mScopeChain, aScript, &mRetValue)) {
mSkip = true;
mRv = EvaluationExceptionToNSResult(mCx);
return mRv;
@@ -242,6 +277,7 @@ nsresult
nsJSUtils::ExecutionContext::CompileAndExec(JS::CompileOptions& aCompileOptions,
const nsAString& aScript)
{
+ MOZ_ASSERT(!mEncodeBytecode, "A JSScript is needed for calling FinishIncrementalEncoding");
if (mSkip) {
return mRv;
}
@@ -249,7 +285,8 @@ nsJSUtils::ExecutionContext::CompileAndExec(JS::CompileOptions& aCompileOptions,
const nsPromiseFlatString& flatScript = PromiseFlatString(aScript);
JS::SourceBufferHolder srcBuf(flatScript.get(), aScript.Length(),
JS::SourceBufferHolder::NoOwnership);
- return CompileAndExec(aCompileOptions, srcBuf);
+ JS::Rooted script(mCx);
+ return CompileAndExec(aCompileOptions, srcBuf, &script);
}
nsresult
@@ -257,6 +294,7 @@ nsJSUtils::ExecutionContext::DecodeAndExec(JS::CompileOptions& aCompileOptions,
mozilla::Vector& aBytecodeBuf,
size_t aBytecodeIndex)
{
+ MOZ_ASSERT(!mEncodeBytecode, "A JSScript is needed for calling FinishIncrementalEncoding");
if (mSkip) {
return mRv;
}
@@ -305,34 +343,6 @@ nsJSUtils::ExecutionContext::DecodeJoinAndExec(void **aOffThreadToken)
return NS_OK;
}
-nsresult
-nsJSUtils::ExecutionContext::JoinEncodeAndExec(void **aOffThreadToken,
- JS::MutableHandle aScript)
-{
- MOZ_ASSERT_IF(aOffThreadToken, !mWantsReturnValue);
- aScript.set(JS::FinishOffThreadScript(mCx, *aOffThreadToken));
- *aOffThreadToken = nullptr; // Mark the token as having been finished.
- if (!aScript) {
- mSkip = true;
- mRv = EvaluationExceptionToNSResult(mCx);
- return mRv;
- }
-
- if (!StartIncrementalEncoding(mCx, aScript)) {
- mSkip = true;
- mRv = EvaluationExceptionToNSResult(mCx);
- return mRv;
- }
-
- if (!JS_ExecuteScript(mCx, mScopeChain, aScript)) {
- mSkip = true;
- mRv = EvaluationExceptionToNSResult(mCx);
- return mRv;
- }
-
- return mRv;
-}
-
nsresult
nsJSUtils::ExecutionContext::ExtractReturnValue(JS::MutableHandle aRetValue)
{
diff --git a/dom/base/nsJSUtils.h b/dom/base/nsJSUtils.h
index 834353a51016..027cd3cfa6f0 100644
--- a/dom/base/nsJSUtils.h
+++ b/dom/base/nsJSUtils.h
@@ -95,6 +95,9 @@ public:
// Should the result be serialized before being returned.
bool mCoerceToString;
+ // Encode the bytecode before it is being executed.
+ bool mEncodeBytecode;
+
#ifdef DEBUG
// Should we set the return value.
bool mWantsReturnValue;
@@ -124,6 +127,15 @@ public:
return *this;
}
+ // When set, this flag records and encodes the bytecode as soon as it is
+ // being compiled, and before it is being executed. The bytecode can then be
+ // requested by using |JS::FinishIncrementalEncoding| with the mutable
+ // handle |aScript| argument of |CompileAndExec| or |JoinAndExec|.
+ ExecutionContext& SetEncodeBytecode(bool aEncodeBytecode) {
+ mEncodeBytecode = aEncodeBytecode;
+ return *this;
+ }
+
// Set the scope chain in which the code should be executed.
void SetScopeChain(const JS::AutoObjectVector& aScopeChain);
@@ -149,7 +161,8 @@ public:
// Compile a script contained in a SourceBuffer, and execute it.
nsresult CompileAndExec(JS::CompileOptions& aCompileOptions,
- JS::SourceBufferHolder& aSrcBuf);
+ JS::SourceBufferHolder& aSrcBuf,
+ JS::MutableHandle aScript);
// Compile a script contained in a string, and execute it.
nsresult CompileAndExec(JS::CompileOptions& aCompileOptions,
@@ -164,11 +177,6 @@ public:
// function will get the result of the decoder by moving it to the main
// thread before starting the execution of the script.
MOZ_MUST_USE nsresult DecodeJoinAndExec(void **aOffThreadToken);
-
- // Similar to JoinAndExec, except that in addition to fecthing the source,
- // we register the fact that we plan to encode its bytecode later.
- MOZ_MUST_USE nsresult JoinEncodeAndExec(void **aOffThreadToken,
- JS::MutableHandle aScript);
};
static nsresult CompileModule(JSContext* aCx,
diff --git a/dom/base/test/mochitest.ini b/dom/base/test/mochitest.ini
index e3fc9e714b8d..3a8a75cb313b 100644
--- a/dom/base/test/mochitest.ini
+++ b/dom/base/test/mochitest.ini
@@ -760,7 +760,6 @@ support-files =
file_js_cache.js
file_js_cache_save_after_load.html
file_js_cache_save_after_load.js
-skip-if = (os == 'linux' || toolkit == 'android') # mochitest are executed on a single core
[test_setInterval_uncatchable_exception.html]
skip-if = debug == false
[test_settimeout_extra_arguments.html]
diff --git a/dom/base/test/test_script_loader_js_cache.html b/dom/base/test/test_script_loader_js_cache.html
index 81ece7ee40a8..d81869587122 100644
--- a/dom/base/test/test_script_loader_js_cache.html
+++ b/dom/base/test/test_script_loader_js_cache.html
@@ -18,22 +18,26 @@
// code path, such that we can assert each code path with a single word.
var scriptLoaderStateMachine = {
"scriptloader_load_source": {
- "scriptloader_encode_and_execute": {
- "scriptloader_bytecode_saved": "bytecode_saved",
- "scriptloader_bytecode_failed": "bytecode_failed"
- },
- "scriptloader_execute": "source_exec"
+ "scriptloader_execute": {
+ "scriptloader_encode": {
+ "scriptloader_bytecode_saved": "bytecode_saved",
+ "scriptloader_bytecode_failed": "bytecode_failed"
+ },
+ "scriptloader_no_encode": "source_exec"
+ }
},
"scriptloader_load_bytecode": {
"scriptloader_fallback": {
// Replicate the top-level state machine without
// "scriptloader_load_bytecode" transition.
"scriptloader_load_source": {
- "scriptloader_encode_and_execute": {
- "scriptloader_bytecode_saved": "fallback_bytecode_saved",
- "scriptloader_bytecode_failed": "fallback_bytecode_failed"
- },
- "scriptloader_execute": "fallback_source_exec"
+ "scriptloader_execute": {
+ "scriptloader_encode": {
+ "scriptloader_bytecode_saved": "fallback_bytecode_saved",
+ "scriptloader_bytecode_failed": "fallback_bytecode_failed"
+ },
+ "scriptloader_no_encode": "fallback_source_exec"
+ }
}
},
"scriptloader_execute": "bytecode_exec"
@@ -93,7 +97,8 @@
iwin.addEventListener("scriptloader_load_bytecode", log_event);
iwin.addEventListener("scriptloader_generate_bytecode", log_event);
iwin.addEventListener("scriptloader_execute", log_event);
- iwin.addEventListener("scriptloader_encode_and_execute", log_event);
+ iwin.addEventListener("scriptloader_encode", log_event);
+ iwin.addEventListener("scriptloader_no_encode", log_event);
iwin.addEventListener("scriptloader_bytecode_saved", log_event);
iwin.addEventListener("scriptloader_bytecode_failed", log_event);
iwin.addEventListener("scriptloader_fallback", log_event);
diff --git a/dom/media/eme/MediaKeySystemAccess.cpp b/dom/media/eme/MediaKeySystemAccess.cpp
index 4773ab012a6a..6a149cac698b 100644
--- a/dom/media/eme/MediaKeySystemAccess.cpp
+++ b/dom/media/eme/MediaKeySystemAccess.cpp
@@ -667,8 +667,21 @@ GetSupportedCapabilities(const CodecType aCodecType,
if (codecs.IsEmpty()) {
// If container normatively implies a specific set of codecs and codec constraints:
// Let parameters be that set.
+ if (isMP4) {
+ if (aCodecType == Audio) {
+ codecs.AppendElement(EME_CODEC_AAC);
+ } else if (aCodecType == Video) {
+ codecs.AppendElement(EME_CODEC_H264);
+ }
+ } else if (isWebM) {
+ if (aCodecType == Audio) {
+ codecs.AppendElement(EME_CODEC_VORBIS);
+ } else if (aCodecType == Video) {
+ codecs.AppendElement(EME_CODEC_VP8);
+ }
+ }
// Otherwise: Continue to the next iteration.
- continue;
+ // (Note: all containers we support have implied codecs, so don't continue here.)
}
// If container type is not strictly a audio/video type, continue to the next iteration.
@@ -940,13 +953,8 @@ GetSupportedConfig(const KeySystemConfig& aKeySystem,
// If the videoCapabilities and audioCapabilities members in candidate
// configuration are both empty, return NotSupported.
- if (aCandidate.mAudioCapabilities.IsEmpty() &&
- aCandidate.mVideoCapabilities.IsEmpty()) {
- EME_LOG("MediaKeySystemConfiguration (label='%s') rejected; "
- "no supported audio or video capabilities specified",
- NS_ConvertUTF16toUTF8(aCandidate.mLabel).get());
- return false;
- }
+ // TODO: Most sites using EME still don't pass capabilities, so we
+ // can't reject on it yet without breaking them. So add this later.
// If the videoCapabilities member in candidate configuration is non-empty:
if (!aCandidate.mVideoCapabilities.IsEmpty()) {
diff --git a/dom/media/test/eme.js b/dom/media/test/eme.js
index 1be161bddacd..3f9fec9caee2 100644
--- a/dom/media/test/eme.js
+++ b/dom/media/test/eme.js
@@ -2,8 +2,8 @@ const CLEARKEY_KEYSYSTEM = "org.w3.clearkey";
const gCencMediaKeySystemConfig = [{
initDataTypes: ['cenc'],
- videoCapabilities: [{ contentType: 'video/mp4; codecs="avc1.42E01E"' }],
- audioCapabilities: [{ contentType: 'audio/mp4; codecs="mp4a.40.2"' }],
+ videoCapabilities: [{ contentType: 'video/mp4' }],
+ audioCapabilities: [{ contentType: 'audio/mp4' }],
}];
function IsMacOSSnowLeopardOrEarlier() {
diff --git a/dom/media/test/test_eme_initDataTypes.html b/dom/media/test/test_eme_initDataTypes.html
index 9d4f119c3398..4821c3cb82eb 100644
--- a/dom/media/test/test_eme_initDataTypes.html
+++ b/dom/media/test/test_eme_initDataTypes.html
@@ -94,7 +94,11 @@ function PrepareInitData(initDataType, initData)
function Test(test) {
return new Promise(function(resolve, reject) {
- navigator.requestMediaKeySystemAccess('org.w3.clearkey', gCencMediaKeySystemConfig)
+ var configs = [{
+ initDataTypes: [test.initDataType],
+ videoCapabilities: [{contentType: 'video/mp4' }],
+ }];
+ navigator.requestMediaKeySystemAccess('org.w3.clearkey', configs)
.then((access) => access.createMediaKeys())
.then((mediaKeys) => {
var session = mediaKeys.createSession(test.sessionType);
diff --git a/dom/media/test/test_eme_missing_pssh.html b/dom/media/test/test_eme_missing_pssh.html
index afe959792ca2..196ced4022b1 100644
--- a/dom/media/test/test_eme_missing_pssh.html
+++ b/dom/media/test/test_eme_missing_pssh.html
@@ -35,8 +35,8 @@
function LoadEME() {
var options = [{
- initDataTypes: ['cenc'],
- audioCapabilities: [{ contentType: 'audio/mp4; codecs="mp4a.40.2"' }],
+ initDataType: 'cenc',
+ audioType: 'audio/mp4; codecs="mp4a.40.2"',
}];
navigator.requestMediaKeySystemAccess("org.w3.clearkey", options)
.then((keySystemAccess) => {
diff --git a/dom/media/test/test_eme_requestKeySystemAccess.html b/dom/media/test/test_eme_requestKeySystemAccess.html
index 5cb2912bac07..21ee91a68cdf 100644
--- a/dom/media/test/test_eme_requestKeySystemAccess.html
+++ b/dom/media/test/test_eme_requestKeySystemAccess.html
@@ -70,13 +70,6 @@ function Test(test) {
});
}
-const AUDIO_WEBM_VORBIS = 'audio/webm; codecs="vorbis"';
-const VIDEO_WEBM_VP8 = 'video/webm; codecs="vp8"';
-const VIDEO_WEBM_VP9 = 'video/webm; codecs="vp9"';
-
-const AUDIO_MP4_AAC = 'audio/mp4; codecs="mp4a.40.2"';
-const VIDEO_MP4_H264 = 'video/mp4; codecs="avc1.42E01E"';
-
var tests = [
{
name: 'Empty keySystem string',
@@ -84,7 +77,7 @@ var tests = [
options: [
{
initDataTypes: ['cenc'],
- videoCapabilities: [{contentType: VIDEO_MP4_H264}],
+ videoCapabilities: [{contentType: 'video/mp4'}],
}
],
shouldPass: false,
@@ -104,15 +97,15 @@ var tests = [
{
label: SUPPORTED_LABEL,
initDataTypes: ['cenc'],
- audioCapabilities: [{contentType: AUDIO_MP4_AAC}],
- videoCapabilities: [{contentType: VIDEO_MP4_H264}],
+ audioCapabilities: [{contentType: 'audio/mp4'}],
+ videoCapabilities: [{contentType: 'video/mp4'}],
}
],
expectedConfig: {
label: SUPPORTED_LABEL,
initDataTypes: ['cenc'],
- audioCapabilities: [{contentType: AUDIO_MP4_AAC}],
- videoCapabilities: [{contentType: VIDEO_MP4_H264}],
+ audioCapabilities: [{contentType: 'audio/mp4'}],
+ videoCapabilities: [{contentType: 'video/mp4'}],
},
shouldPass: true,
},
@@ -122,7 +115,7 @@ var tests = [
options: [
{
initDataTypes: ['cenc'],
- videoCapabilities: [{contentType: VIDEO_MP4_H264}],
+ videoCapabilities: [{contentType: 'video/mp4'}],
}
],
shouldPass: false,
@@ -132,7 +125,7 @@ var tests = [
options: [
{
initDataTypes: ['bogus'],
- audioCapabilities: [{contentType: AUDIO_MP4_AAC}],
+ audioCapabilities: [{contentType: 'audio/mp4'}],
}
],
shouldPass: false,
@@ -143,13 +136,13 @@ var tests = [
{
label: SUPPORTED_LABEL,
initDataTypes: ['bogus', 'invalid', 'cenc'],
- audioCapabilities: [{contentType: AUDIO_MP4_AAC}],
+ audioCapabilities: [{contentType: 'audio/mp4'}],
}
],
expectedConfig: {
label: SUPPORTED_LABEL,
initDataTypes: ['cenc'],
- audioCapabilities: [{contentType: AUDIO_MP4_AAC}],
+ audioCapabilities: [{contentType: 'audio/mp4'}],
},
shouldPass: true,
},
@@ -168,7 +161,7 @@ var tests = [
options: [
{
initDataTypes: ['cenc'],
- videoCapabilities: [{contentType: VIDEO_MP4_H264}],
+ videoCapabilities: [{contentType: 'video/mp4'}],
distinctiveIdentifier: 'bogus',
persistentState: 'bogus',
}
@@ -180,7 +173,7 @@ var tests = [
options: [
{
initDataTypes: ['cenc'],
- videoCapabilities: [{contentType: VIDEO_MP4_H264}],
+ videoCapabilities: [{contentType: 'video/mp4'}],
distinctiveIdentifier: 'required',
}
],
@@ -191,7 +184,7 @@ var tests = [
options: [
{
initDataTypes: ['cenc'],
- videoCapabilities: [{contentType: VIDEO_MP4_H264}],
+ videoCapabilities: [{contentType: 'video/mp4'}],
persistentState: 'bogus',
}
],
@@ -202,7 +195,7 @@ var tests = [
options: [
{
initDataTypes: ['cenc'],
- videoCapabilities: [{contentType: VIDEO_MP4_H264, robustness: 'very much so'}],
+ videoCapabilities: [{contentType: 'video/mp4', robustness: 'very much so'}],
}
],
shouldPass: false,
@@ -213,14 +206,14 @@ var tests = [
{
label: SUPPORTED_LABEL,
initDataTypes: ['cenc'],
- videoCapabilities: [{contentType: VIDEO_MP4_H264}],
+ videoCapabilities: [{contentType: 'video/mp4'}],
unexpectedEntry: 'this should be ignored',
}
],
expectedConfig: {
label: SUPPORTED_LABEL,
initDataTypes: ['cenc'],
- videoCapabilities: [{contentType: VIDEO_MP4_H264}],
+ videoCapabilities: [{contentType: 'video/mp4'}],
},
shouldPass: true,
},
@@ -234,13 +227,13 @@ var tests = [
{
label: SUPPORTED_LABEL,
initDataTypes: ['cenc'],
- videoCapabilities: [{contentType: VIDEO_MP4_H264}],
+ videoCapabilities: [{contentType: 'video/mp4'}],
}
],
expectedConfig: {
label: SUPPORTED_LABEL,
initDataTypes: ['cenc'],
- videoCapabilities: [{contentType: VIDEO_MP4_H264}],
+ videoCapabilities: [{contentType: 'video/mp4'}],
},
shouldPass: true,
},
@@ -249,7 +242,7 @@ var tests = [
options: [
{
initDataTypes: ['cenc'],
- videoCapabilities: [{contentType: VIDEO_MP4_H264}],
+ videoCapabilities: [{contentType: 'video/mp4'}],
sessionTypes: ['persistent-license'],
persistentState: 'optional',
}
@@ -261,7 +254,7 @@ var tests = [
options: [
{
initDataTypes: ['cenc'],
- videoCapabilities: [{contentType: VIDEO_MP4_H264}],
+ videoCapabilities: [{contentType: 'video/mp4'}],
sessionTypes: ['persistent-usage-record'],
persistentState: 'optional',
}
@@ -274,13 +267,13 @@ var tests = [
{
label: SUPPORTED_LABEL,
initDataTypes: ['cenc'],
- audioCapabilities: [{contentType: AUDIO_MP4_AAC}],
+ audioCapabilities: [{contentType: 'audio/mp4'}],
}
],
expectedConfig: {
label: SUPPORTED_LABEL,
initDataTypes: ['cenc'],
- audioCapabilities: [{contentType: AUDIO_MP4_AAC}],
+ audioCapabilities: [{contentType: 'audio/mp4'}],
},
shouldPass: true,
},
@@ -290,13 +283,13 @@ var tests = [
{
label: SUPPORTED_LABEL,
initDataTypes: ['cenc'],
- audioCapabilities: [{contentType: AUDIO_MP4_AAC}],
+ audioCapabilities: [{contentType: 'audio/mp4; codecs="mp4a.40.2"'}],
}
],
expectedConfig: {
label: SUPPORTED_LABEL,
initDataTypes: ['cenc'],
- audioCapabilities: [{contentType: AUDIO_MP4_AAC}],
+ audioCapabilities: [{contentType: 'audio/mp4; codecs="mp4a.40.2"'}],
},
shouldPass: true,
},
@@ -346,13 +339,13 @@ var tests = [
{
label: SUPPORTED_LABEL,
initDataTypes: ['cenc'],
- videoCapabilities: [{contentType: VIDEO_MP4_H264}],
+ videoCapabilities: [{contentType: 'video/mp4; codecs="avc1.42E01E"'}],
}
],
expectedConfig: {
label: SUPPORTED_LABEL,
initDataTypes: ['cenc'],
- videoCapabilities: [{contentType: VIDEO_MP4_H264}],
+ videoCapabilities: [{contentType: 'video/mp4; codecs="avc1.42E01E"'}],
},
shouldPass: true,
},
@@ -382,15 +375,15 @@ var tests = [
{
label: SUPPORTED_LABEL,
initDataTypes: ['cenc'],
- audioCapabilities: [{contentType: AUDIO_MP4_AAC}],
- videoCapabilities: [{contentType: VIDEO_MP4_H264}],
+ videoCapabilities: [{contentType: 'video/mp4; codecs="avc1.42E01E"'}],
+ audioCapabilities: [{contentType: 'audio/mp4; codecs="mp4a.40.2"'}],
}
],
expectedConfig: {
label: SUPPORTED_LABEL,
initDataTypes: ['cenc'],
- audioCapabilities: [{contentType: AUDIO_MP4_AAC}],
- videoCapabilities: [{contentType: VIDEO_MP4_H264}],
+ videoCapabilities: [{contentType: 'video/mp4; codecs="avc1.42E01E"'}],
+ audioCapabilities: [{contentType: 'audio/mp4; codecs="mp4a.40.2"'}],
},
shouldPass: true,
},
@@ -400,13 +393,13 @@ var tests = [
{
label: SUPPORTED_LABEL,
initDataTypes: ['webm'],
- videoCapabilities: [{contentType: VIDEO_WEBM_VP9}],
+ videoCapabilities: [{contentType: 'video/webm'}],
}
],
expectedConfig: {
label: SUPPORTED_LABEL,
initDataTypes: ['webm'],
- videoCapabilities: [{contentType: VIDEO_WEBM_VP9}],
+ videoCapabilities: [{contentType: 'video/webm'}],
},
shouldPass: true,
},
@@ -416,13 +409,13 @@ var tests = [
{
label: SUPPORTED_LABEL,
initDataTypes: ['webm'],
- audioCapabilities: [{contentType: AUDIO_WEBM_VORBIS}],
+ audioCapabilities: [{contentType: 'audio/webm'}],
}
],
expectedConfig: {
label: SUPPORTED_LABEL,
initDataTypes: ['webm'],
- audioCapabilities: [{contentType: AUDIO_WEBM_VORBIS}],
+ audioCapabilities: [{contentType: 'audio/webm'}],
},
shouldPass: true,
},
@@ -432,15 +425,15 @@ var tests = [
{
label: SUPPORTED_LABEL,
initDataTypes: ['webm'],
- videoCapabilities: [{contentType: VIDEO_WEBM_VP8}],
- audioCapabilities: [{contentType: AUDIO_WEBM_VORBIS}],
+ videoCapabilities: [{contentType: 'video/webm;codecs="vp8"'}],
+ audioCapabilities: [{contentType: 'audio/webm;codecs="vorbis"'}],
}
],
expectedConfig: {
label: SUPPORTED_LABEL,
initDataTypes: ['webm'],
- videoCapabilities: [{contentType: VIDEO_WEBM_VP8}],
- audioCapabilities: [{contentType: AUDIO_WEBM_VORBIS}],
+ videoCapabilities: [{contentType: 'video/webm;codecs="vp8"'}],
+ audioCapabilities: [{contentType: 'audio/webm;codecs="vorbis"'}],
},
shouldPass: true,
},
@@ -450,15 +443,15 @@ var tests = [
{
label: SUPPORTED_LABEL,
initDataTypes: ['webm'],
- videoCapabilities: [{contentType: VIDEO_WEBM_VP9}],
- audioCapabilities: [{contentType: AUDIO_WEBM_VORBIS}],
+ videoCapabilities: [{contentType: 'video/webm;codecs="vp9"'}],
+ audioCapabilities: [{contentType: 'audio/webm;codecs="vorbis"'}],
}
],
expectedConfig: {
label: SUPPORTED_LABEL,
initDataTypes: ['webm'],
- videoCapabilities: [{contentType: VIDEO_WEBM_VP9}],
- audioCapabilities: [{contentType: AUDIO_WEBM_VORBIS}],
+ videoCapabilities: [{contentType: 'video/webm;codecs="vp9"'}],
+ audioCapabilities: [{contentType: 'audio/webm;codecs="vorbis"'}],
},
shouldPass: true,
},
@@ -472,15 +465,6 @@ var tests = [
],
shouldPass: false,
},
- {
- name: 'Unspecified capabilities',
- options: [
- {
- initDataTypes: ['cenc'],
- }
- ],
- shouldPass: false,
- },
];
function beginTest() {
diff --git a/dom/media/test/test_eme_sample_groups_playback.html b/dom/media/test/test_eme_sample_groups_playback.html
index 46d5cbf11f54..77aa59f07f7f 100644
--- a/dom/media/test/test_eme_sample_groups_playback.html
+++ b/dom/media/test/test_eme_sample_groups_playback.html
@@ -58,8 +58,8 @@
function LoadEME() {
var options = [{
- initDataTypes: ['cenc'],
- videoCapabilities: [{contentType: test.track.type}],
+ initDataType: "cenc",
+ videoType: test.track.type,
}];
return navigator.requestMediaKeySystemAccess("org.w3.clearkey", options)
@@ -143,4 +143,4 @@