95e272386c
This modifies our browser package and test scripts to use the userAgent instead of webkitStartDart (which is gone) to determine if we have native dart support. I'm TBR-ing to get rid of a ton of warnings on the Dartium bots (they are trying to run both native tests (successfully) and compiled-to-js tests (warning no js file)). E.g., see HttpServer warnings on this otherwise green run: http://chromegw.corp.google.com/i/client.dart/builders/dartium-mac-inc-be/builds/634/steps/drt_core_checked_tests/logs/stdio Siggi: you have comments elsewhere around removing/refactoring when webkitStartDart is gone. They are still there. TBR=sigmund@google.com,ricow@google.com Review URL: https://codereview.chromium.org//52023002 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@29515 260f80e4-7a28-3924-810f-c04153c831b5
36 lines
1.3 KiB
JavaScript
36 lines
1.3 KiB
JavaScript
// Copyright (c) 2013, 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.
|
|
|
|
(function() {
|
|
// Bootstrap support for Dart scripts on the page as this script.
|
|
if (navigator.userAgent.indexOf('(Dart)') === -1) {
|
|
// TODO:
|
|
// - Support in-browser compilation.
|
|
// - Handle inline Dart scripts.
|
|
|
|
// Fall back to compiled JS. Run through all the scripts and
|
|
// replace them if they have a type that indicate that they source
|
|
// in Dart code.
|
|
//
|
|
// <script type="application/dart" src="..."></script>
|
|
//
|
|
var scripts = document.getElementsByTagName("script");
|
|
var length = scripts.length;
|
|
for (var i = 0; i < length; ++i) {
|
|
if (scripts[i].type == "application/dart") {
|
|
// Remap foo.dart to foo.dart.js.
|
|
if (scripts[i].src && scripts[i].src != '') {
|
|
var script = document.createElement('script');
|
|
script.src = scripts[i].src.replace(/\.dart(?=\?|$)/, '.dart.js');
|
|
var parent = scripts[i].parentNode;
|
|
// TODO(vsm): Find a solution for issue 8455 that works with more
|
|
// than one script.
|
|
document.currentScript = script;
|
|
parent.replaceChild(script, scripts[i]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
})();
|