Commit ee70e70b authored by Luciano Pacheco's avatar Luciano Pacheco Committed by Commit Bot

Files app: Fix FileManagerJsTest to work without DOMv0 and HTML Imports

Change the generated HTML to include the HTML import polyfil and to not
include the scripts from <cr_elements> because they'll be included via
HTML imports by the elements that use them.

Change the test harness to detect if HTML Import polyfil is available
and wait for imports to finish before starting the test.

Bug: 1111393
Change-Id: I2a8d55bee39f8386e75183bcbb79fbbf15204d03
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2362167
Commit-Queue: Luciano Pacheco <lucmult@chromium.org>
Reviewed-by: default avatardpapad <dpapad@chromium.org>
Reviewed-by: default avatarMason Freed <masonfreed@chromium.org>
Cr-Commit-Position: refs/heads/master@{#799934}
parent b23d9998
...@@ -1669,9 +1669,6 @@ bool ChromeContentRendererClient::RequiresWebComponentsV0(const GURL& url) { ...@@ -1669,9 +1669,6 @@ bool ChromeContentRendererClient::RequiresWebComponentsV0(const GURL& url) {
host_piece == chrome::kChromeUIOSSettingsHost || host_piece == chrome::kChromeUIOSSettingsHost ||
// TODO(crbug.com/1022192): Remove when migrated to Polymer3. // TODO(crbug.com/1022192): Remove when migrated to Polymer3.
host_piece == chrome::kChromeUIPasswordChangeHost || host_piece == chrome::kChromeUIPasswordChangeHost ||
// TODO(crbug.com/1111393): Remove when migrated away from HTML
// imports.
host_piece == "file_manager_test" ||
#endif #endif
false; false;
} }
......
...@@ -24,6 +24,8 @@ window.addEventListener('error', function(e) { ...@@ -24,6 +24,8 @@ window.addEventListener('error', function(e) {
_SCRIPT = r'<script src="%s"></script>' _SCRIPT = r'<script src="%s"></script>'
_IMPORT = r'<link rel="import" href="%s">' _IMPORT = r'<link rel="import" href="%s">'
_HTML_IMPORT_POLYFIL = _SCRIPT % (
'chrome://resources/polymer/v1_0/html-imports/html-imports.min.js')
_HTML_FOOTER = r""" _HTML_FOOTER = r"""
</body> </body>
...@@ -45,6 +47,10 @@ def _process_deps(unique_deps, html_import, target_name): ...@@ -45,6 +47,10 @@ def _process_deps(unique_deps, html_import, target_name):
Iterator of strings, each string is a HTML tag <script> or <link>. Iterator of strings, each string is a HTML tag <script> or <link>.
""" """
for dep in unique_deps: for dep in unique_deps:
# Scripts from cr_elements are included via HTML imports.
if '/cr_elements/' in dep:
continue
# Special case for jstemplate which has multiple files but we server all of # Special case for jstemplate which has multiple files but we server all of
# them combined from chrome://resources/js/jstemplate_compiled.js # them combined from chrome://resources/js/jstemplate_compiled.js
if '/jstemplate/' in dep: if '/jstemplate/' in dep:
...@@ -104,6 +110,10 @@ def _process(deps, output_filename, mocks, html_import, target_name): ...@@ -104,6 +110,10 @@ def _process(deps, output_filename, mocks, html_import, target_name):
with open(output_filename, 'w') as out: with open(output_filename, 'w') as out:
out.write(_HTML_FILE) out.write(_HTML_FILE)
if html_import:
out.write(_HTML_IMPORT_POLYFIL + '\n')
for dep in _process_deps(mocks, html_import, target_name): for dep in _process_deps(mocks, html_import, target_name):
out.write(dep + '\n') out.write(dep + '\n')
for dep in _process_deps(deps, html_import, target_name): for dep in _process_deps(deps, html_import, target_name):
......
...@@ -227,7 +227,14 @@ function startTesting() { ...@@ -227,7 +227,14 @@ function startTesting() {
setTimeout(startTesting, 1000); setTimeout(startTesting, 1000);
return; return;
} }
continueTesting();
if (window.HTMLImports && window.HTMLImports.whenReady) {
/// When there is a HTML Import polyfill wait all imports to finish before
// starting the test.
window.HTMLImports.whenReady(continueTesting);
} else {
continueTesting();
}
} }
/** /**
......
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