mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
4d6a633bba
The -*- file variable lines -*- establish per-file settings that Emacs will pick up. This patch makes the following changes to those lines (and touches nothing else): - Never set the buffer's mode. Years ago, Emacs did not have a good JavaScript mode, so it made sense to use Java or C++ mode in .js files. However, Emacs has had js-mode for years now; it's perfectly serviceable, and is available and enabled by default in all major Emacs packagings. Selecting a mode in the -*- file variable line -*- is almost always the wrong thing to do anyway. It overrides Emacs's default choice, which is (now) reasonable; and even worse, it overrides settings the user might have made in their '.emacs' file for that file extension. It's only useful when there's something specific about that particular file that makes a particular mode appropriate. - Correctly propagate settings that establish the correct indentation level for this file: c-basic-offset and js2-basic-offset should be js-indent-level. Whatever value they're given should be preserved; different parts of our tree use different indentation styles. - We don't use tabs in Mozilla JS code. Always set indent-tabs-mode: nil. Remove tab-width: settings, at least in files that don't contain tab characters. - Remove js2-mode settings that belong in the user's .emacs file, like js2-skip-preprocessor-directives.
85 lines
2.9 KiB
JavaScript
85 lines
2.9 KiB
JavaScript
// -*- 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/. */
|
|
|
|
"use strict";
|
|
|
|
const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
|
|
|
|
Cu.import("resource://gre/modules/Services.jsm");
|
|
|
|
function ok(passed, text) {
|
|
do_report_result(passed, text, Components.stack.caller, false);
|
|
}
|
|
|
|
// The chrome window
|
|
let chromeWin;
|
|
|
|
// Track the <browser> where the tests are happening
|
|
let browser;
|
|
|
|
function middle(element) {
|
|
let rect = element.getBoundingClientRect();
|
|
let x = (rect.right - rect.left) / 2 + rect.left;
|
|
let y = (rect.bottom - rect.top) / 2 + rect.top;
|
|
return [x, y];
|
|
}
|
|
|
|
add_test(function setup_browser() {
|
|
chromeWin = Services.wm.getMostRecentWindow("navigator:browser");
|
|
let BrowserApp = chromeWin.BrowserApp;
|
|
|
|
do_register_cleanup(function cleanup() {
|
|
BrowserApp.closeTab(BrowserApp.getTabForBrowser(browser));
|
|
});
|
|
|
|
let url = "http://mochi.test:8888/tests/robocop/video_discovery.html";
|
|
browser = BrowserApp.addTab(url, { selected: true, parentId: BrowserApp.selectedTab.id }).browser;
|
|
browser.addEventListener("load", function startTests(event) {
|
|
browser.removeEventListener("load", startTests, true);
|
|
Services.tm.mainThread.dispatch(run_next_test, Ci.nsIThread.DISPATCH_NORMAL);
|
|
}, true);
|
|
});
|
|
|
|
let videoDiscoveryTests = [
|
|
{ id: "simple-mp4", source: "http://mochi.test:8888/simple.mp4", poster: "http://mochi.test:8888/simple.png", text: "simple video with mp4 src" },
|
|
{ id: "simple-fail", pass: false, text: "simple video with no mp4 src" },
|
|
{ id: "with-sources-mp4", source: "http://mochi.test:8888/simple.mp4", text: "video with mp4 extension source child" },
|
|
{ id: "with-sources-fail", pass: false, text: "video with no mp4 extension source child" },
|
|
{ id: "with-sources-mimetype", source: "http://mochi.test:8888/simple-video-mp4", text: "video with mp4 mimetype source child" },
|
|
{ id: "video-overlay", source: "http://mochi.test:8888/simple.mp4", text: "div overlay covering a simple video with mp4 src" }
|
|
];
|
|
|
|
function execute_video_test(test) {
|
|
let element = browser.contentDocument.getElementById(test.id);
|
|
if (element) {
|
|
let [x, y] = middle(element);
|
|
let video = chromeWin.CastingApps.getVideo(element, x, y);
|
|
if (video) {
|
|
let matchPoster = (test.poster == video.poster);
|
|
let matchSource = (test.source == video.source);
|
|
ok(matchPoster && matchSource && test.pass, test.text);
|
|
} else {
|
|
ok(!test.pass, test.text);
|
|
}
|
|
} else {
|
|
ok(false, "test element not found: [" + test.id + "]");
|
|
}
|
|
run_next_test();
|
|
}
|
|
|
|
let videoTest;
|
|
while ((videoTest = videoDiscoveryTests.shift())) {
|
|
if (!("poster" in videoTest)) {
|
|
videoTest.poster = "";
|
|
}
|
|
if (!("pass" in videoTest)) {
|
|
videoTest.pass = true;
|
|
}
|
|
|
|
add_test(execute_video_test.bind(this, videoTest));
|
|
}
|
|
|
|
run_next_test();
|