Commit 8e3f3bf7 authored by Jérémie Boulic's avatar Jérémie Boulic Committed by Chromium LUCI CQ

Video player: Generate JS modules for video player background deps

JS Modules for the following files in ui/file_manger/video_player/js:
- background.js
- error_util.js
- test_util.js

Add the main_background.m.js to act as the entry point for the
background page.

Bug: 1133186
Change-Id: I0c1a205047c85f70e4629d5a3f52ddfcfcbedd7c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2596467
Commit-Queue: Jeremie Boulic <jboulic@chromium.org>
Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Cr-Commit-Position: refs/heads/master@{#837950}
parent 39349b49
...@@ -7,9 +7,21 @@ import("//third_party/closure_compiler/js_unit_tests.gni") ...@@ -7,9 +7,21 @@ import("//third_party/closure_compiler/js_unit_tests.gni")
import("//ui/file_manager/base/gn/js_test_gen_html.gni") import("//ui/file_manager/base/gn/js_test_gen_html.gni")
import("//ui/webui/resources/tools/js_modulizer.gni") import("//ui/webui/resources/tools/js_modulizer.gni")
group("closure_compile") {
testonly = true
deps = [
":closure_compile_jsmodules",
":closure_compile_module",
":js_test_gen_html_modules_type_check_auto",
]
}
js_type_check("closure_compile_jsmodules") { js_type_check("closure_compile_jsmodules") {
uses_js_modules = true uses_js_modules = true
deps = [ deps = [
":background.m",
":error_util.m",
":test_util.m",
":video_player_metrics.m", ":video_player_metrics.m",
":video_player_native_controls.m", ":video_player_native_controls.m",
] ]
...@@ -46,9 +58,41 @@ js_library("background") { ...@@ -46,9 +58,41 @@ js_library("background") {
] ]
} }
js_library("background.m") {
sources = [ "$root_gen_dir/ui/file_manager/video_player/js/background.m.js" ]
deps = [
"//ui/file_manager/externs/background:background_base.m",
"//ui/file_manager/file_manager/background/js:app_window_wrapper.m",
"//ui/file_manager/file_manager/background/js:background_base.m",
"//ui/file_manager/file_manager/common/js:util.m",
"//ui/webui/resources/js:assert.m",
]
extra_deps = [ ":modulize" ]
}
js_library("error_util") { js_library("error_util") {
} }
js_library("error_util.m") {
sources = [ "$root_gen_dir/ui/file_manager/video_player/js/error_util.m.js" ]
extra_deps = [ ":modulize" ]
}
js_library("test_util") {
}
js_library("test_util.m") {
sources = [ "$root_gen_dir/ui/file_manager/video_player/js/test_util.m.js" ]
deps = [
":background.m",
"//ui/file_manager/file_manager/background/js:test_util_base.m",
]
extra_deps = [ ":modulize" ]
}
js_library("video_player_native_controls") { js_library("video_player_native_controls") {
deps = [ deps = [
"//ui/file_manager/base/js:app_util", "//ui/file_manager/base/js:app_util",
...@@ -121,12 +165,12 @@ js_test_gen_html("js_test_gen_html_modules") { ...@@ -121,12 +165,12 @@ js_test_gen_html("js_test_gen_html_modules") {
] ]
} }
group("closure_compile") { js_library("main_background.m") {
testonly = true
deps = [ deps = [
":closure_compile_jsmodules", ":background.m",
":closure_compile_module", ":error_util.m",
":js_test_gen_html_modules_type_check_auto", ":test_util.m",
":video_player_metrics.m",
] ]
} }
...@@ -134,5 +178,8 @@ js_modulizer("modulize") { ...@@ -134,5 +178,8 @@ js_modulizer("modulize") {
input_files = [ input_files = [
"video_player_native_controls.js", "video_player_native_controls.js",
"video_player_metrics.js", "video_player_metrics.js",
"error_util.js",
"test_util.js",
"background.js",
] ]
} }
...@@ -2,6 +2,14 @@ ...@@ -2,6 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// clang-format off
// #import {assert} from 'chrome://resources/js/assert.m.js';
// #import {AppWindowWrapper} from '../../file_manager/background/js/app_window_wrapper.m.js';
// #import {util} from '../../file_manager/common/js/util.m.js';
// #import {BackgroundBaseImpl} from '../../file_manager/background/js/background_base.m.js';
// #import {BackgroundBase} from '../../externs/background/background_base.m.js';
// clang-format on
/** /**
* Use maximum size and let ash downsample the icon. * Use maximum size and let ash downsample the icon.
* *
...@@ -47,7 +55,7 @@ const generateWindowId = (function() { ...@@ -47,7 +55,7 @@ const generateWindowId = (function() {
* playing. * playing.
* @return {!Promise} Promise to be fulfilled on success, or rejected on error. * @return {!Promise} Promise to be fulfilled on success, or rejected on error.
*/ */
function openVideoPlayerWindow(urls) { /* #export */ function openVideoPlayerWindow(urls) {
let position = 0; let position = 0;
const startUrl = (position < urls.length) ? urls[position] : ''; const startUrl = (position < urls.length) ? urls[position] : '';
let windowId = null; let windowId = null;
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* @fileoverview Entry point for it replaces background_scripts.js.
*/
import './error_util.m.js';
import './test_util.m.js';
import './video_player_metrics.m.js';
import './background.m.js';
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// #import {openVideoPlayerWindow} from './background.m.js';
// #import {test} from '../../file_manager/background/js/test_util_base.m.js';
/** /**
* Returns if a video element playing the specified file meet the condition * Returns if a video element playing the specified file meet the condition
* which is given by a parameter. * which is given by a parameter.
...@@ -10,11 +13,11 @@ ...@@ -10,11 +13,11 @@
* @param {function(!Element):boolean} testFunction * @param {function(!Element):boolean} testFunction
*/ */
function testElement(filename, testFunction) { function testElement(filename, testFunction) {
for (var appId in window.appWindows) { for (const appId in window.appWindows) {
var contentWindow = window.appWindows[appId].contentWindow; const contentWindow = window.appWindows[appId].contentWindow;
if (contentWindow && if (contentWindow &&
contentWindow.document.title === filename) { contentWindow.document.title === filename) {
var element = contentWindow.document.querySelector('video'); const element = contentWindow.document.querySelector('video');
if (element && testFunction(element)) { if (element && testFunction(element)) {
return true; return true;
} }
...@@ -62,7 +65,7 @@ test.util.sync.hasSubtitle = function(filename) { ...@@ -62,7 +65,7 @@ test.util.sync.hasSubtitle = function(filename) {
* @param {Window} contentWindow Video player window to be chacked toOB. * @param {Window} contentWindow Video player window to be chacked toOB.
*/ */
test.util.sync.loadMockCastExtension = function(contentWindow) { test.util.sync.loadMockCastExtension = function(contentWindow) {
var script = contentWindow.document.createElement('script'); const script = contentWindow.document.createElement('script');
script.src = script.src =
'chrome-extension://ljoplibgfehghmibaoaepfagnmbbfiga/' + 'chrome-extension://ljoplibgfehghmibaoaepfagnmbbfiga/' +
'cast_extension_mock/load.js'; 'cast_extension_mock/load.js';
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment