mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 04:27:17 +00:00
Support dart and js scripts in HTML tests, on dartium.
BUG= R=ricow@google.com Review URL: https://codereview.chromium.org//705733003 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41569 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
parent
ca91f9f770
commit
562fb318a8
|
@ -27,6 +27,7 @@ custom/element_upgrade_test: Fail # Issue 17298
|
|||
custom/created_callback_test: Fail # Support for created constructor.
|
||||
fontface_loaded_test: Fail # Support for promises.
|
||||
storage_quota_test: Fail # Support for promises.
|
||||
scripts_htmltest: Fail # Issue 21514
|
||||
|
||||
[ $compiler == dart2js && ($runtime == safari || $runtime == safarimobilesim || $runtime == ff || $ie) ]
|
||||
custom/entered_left_view_test/viewless_document: Fail # Polyfill does not handle this
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<!DOCTYPE html>
|
||||
<!--
|
||||
Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
||||
Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
|
||||
for details. All rights reserved. Use of this source code is governed by a
|
||||
BSD-style license that can be found in the LICENSE file.
|
||||
-->
|
||||
|
@ -14,20 +14,20 @@ END_HTML_DART_TEST
|
|||
-->
|
||||
<html>
|
||||
<head>
|
||||
<script>window.parent.dispatchEvent(new Event('detect_errors'));</script>
|
||||
<title>No Linked Scripts HTML test</title>
|
||||
<script>window.parent.dispatchEvent(new Event('detect_errors'));</script>
|
||||
<title>No Linked Scripts HTML test</title>
|
||||
</head><body>
|
||||
<h1>No Linked Scripts HTML test</h1>
|
||||
<script>
|
||||
window.postMessage('fisk', '*');
|
||||
window.postMessage('ged', '*');
|
||||
window.postMessage('fisk', '*');
|
||||
<h1>No Linked Scripts HTML test</h1>
|
||||
<script>
|
||||
window.postMessage('fisk', '*');
|
||||
window.postMessage('ged', '*');
|
||||
window.postMessage('fisk', '*');
|
||||
|
||||
function delayed() {
|
||||
function delayed() {
|
||||
parent.postMessage('ko', '*');
|
||||
window.postMessage('hest', '*');
|
||||
}
|
||||
setTimeout(delayed, 5000);
|
||||
</script>
|
||||
setTimeout(delayed, 5000);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
24
tests/html/scripts_htmltest.html
Normal file
24
tests/html/scripts_htmltest.html
Normal file
|
@ -0,0 +1,24 @@
|
|||
<!DOCTYPE html>
|
||||
<!--
|
||||
Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
|
||||
for details. All rights reserved. Use of this source code is governed by a
|
||||
BSD-style license that can be found in the LICENSE file.
|
||||
-->
|
||||
<!--
|
||||
START_HTML_DART_TEST
|
||||
{
|
||||
"scripts": ["scripts_test_dart.dart", "scripts_test_js.js"],
|
||||
"expectedMessages": ["crab", "fish", "squid", "sea urchin"]
|
||||
}
|
||||
END_HTML_DART_TEST
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<script>window.parent.dispatchEvent(new Event('detect_errors'));</script>
|
||||
<title>Scripts HTML test</title>
|
||||
</head><body>
|
||||
<h1>Scripts HTML test</h1>
|
||||
<script src="scripts_test_dart.dart" type="application/dart"></script>
|
||||
<script src="scripts_test_js.js"></script>
|
||||
</body>
|
||||
</html>
|
16
tests/html/scripts_test_dart.dart
Normal file
16
tests/html/scripts_test_dart.dart
Normal file
|
@ -0,0 +1,16 @@
|
|||
// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
library ScriptsTestDart;
|
||||
import 'dart:html';
|
||||
import 'dart:async';
|
||||
|
||||
main() {
|
||||
window.postMessage('squid', '*');
|
||||
window.postMessage('tiger', '*'); // Unexpected message OK.
|
||||
new Timer(new Duration(seconds: 1), () {
|
||||
window.postMessage('squid', '*'); // Duplicate message OK.
|
||||
window.postMessage('sea urchin', '*');
|
||||
});
|
||||
}
|
12
tests/html/scripts_test_js.js
Normal file
12
tests/html/scripts_test_js.js
Normal file
|
@ -0,0 +1,12 @@
|
|||
// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
window.postMessage('fish', '*');
|
||||
|
||||
function delayed() {
|
||||
window.postMessage('cow', '*'); // Unexpected message OK.
|
||||
parent.postMessage('weasel', '*'); // Message to parent OK.
|
||||
window.postMessage('crab', '*');
|
||||
}
|
||||
setTimeout(delayed, 500);
|
|
@ -45,3 +45,21 @@ String getContents(HtmlTestInformation info) {
|
|||
String contents = new File(info.filePath.toNativePath()).readAsStringSync();
|
||||
return contents.replaceFirst(htmlAnnotation, '');
|
||||
}
|
||||
|
||||
String makeFailingHtmlFile(String message) {
|
||||
return '''
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<script>window.parent.dispatchEvent(new Event('detect_errors'));</script>
|
||||
<title>Failing HTML test</title>
|
||||
</head><body>
|
||||
<h1>Failing HTML test</h1>
|
||||
$message
|
||||
<script>
|
||||
throw "HTML test failed: $message";
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
''';
|
||||
}
|
||||
|
|
|
@ -1165,21 +1165,51 @@ class StandardTestSuite extends TestSuite {
|
|||
final String runtime = configuration['runtime'];
|
||||
|
||||
if (info is HtmlTestInformation) {
|
||||
if (compiler != 'none' || runtime != 'dartium') {
|
||||
// TODO(whesse): Enable compilation of scripts to dart2js, and
|
||||
// rewriting of script links in html file. Currently unimplemented.
|
||||
return;
|
||||
final String tempDir = createOutputDirectory(info.filePath, '');
|
||||
final Uri tempUri = new Uri.file('$tempDir/');
|
||||
final Uri htmlFile = tempUri.resolve(filePath.filename);
|
||||
new File.fromUri(htmlFile).writeAsStringSync(htmlTest.getContents(info));
|
||||
|
||||
void createFailingTest(String message) {
|
||||
var msg = "$message: ${info.filePath}";
|
||||
DebugLogger.warning(msg);
|
||||
new File.fromUri(htmlFile).writeAsStringSync(
|
||||
htmlTest.makeFailingHtmlFile(msg));
|
||||
}
|
||||
if (info.scripts.length > 0) {
|
||||
// TODO(whesse): Copy scripts into output directory.
|
||||
return;
|
||||
Uri testUri = new Uri.file(filePath.toNativePath());
|
||||
for (String scriptPath in info.scripts) {
|
||||
if (!scriptPath.endsWith('.dart') && !scriptPath.endsWith('.js')) {
|
||||
createFailingTest(
|
||||
'HTML test scripts must be dart or javascript: $scriptPath');
|
||||
break;
|
||||
}
|
||||
Uri uri = Uri.parse(scriptPath);
|
||||
if (uri.isAbsolute) {
|
||||
createFailingTest(
|
||||
'HTML test scripts must have relative paths: $scriptPath');
|
||||
break;
|
||||
}
|
||||
if (uri.pathSegments.length > 1) {
|
||||
createFailingTest(
|
||||
'HTML test scripts must be in test directory: $scriptPath');
|
||||
break;
|
||||
}
|
||||
Uri script = testUri.resolveUri(uri);
|
||||
if (compiler == 'none' || scriptPath.endsWith('.js')) {
|
||||
Uri copiedScript = tempUri.resolveUri(uri);
|
||||
new File.fromUri(copiedScript).writeAsStringSync(
|
||||
new File.fromUri(script).readAsStringSync());
|
||||
} else {
|
||||
// TODO(21514): Compile scripts into output directory.
|
||||
createFailingTest('HTML test scripts don\'t support dart2js yet');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
final String tempDir = createOutputDirectory(info.filePath, '');
|
||||
final String htmlFile = '$tempDir/${filePath.filename}';
|
||||
new File(htmlFile).writeAsStringSync(htmlTest.getContents(info));
|
||||
|
||||
String testDisplayName = '$suiteName/$testName';
|
||||
var htmlPath = _createUrlPathFromFile(new Path(htmlFile));
|
||||
var htmlPath = _createUrlPathFromFile(new Path(htmlFile.toFilePath()));
|
||||
var fullHtmlPath = _getUriForBrowserTest(info, htmlPath,
|
||||
null, null);
|
||||
var commands = [CommandBuilder.instance.getBrowserHtmlTestCommand(
|
||||
|
|
Loading…
Reference in a new issue