Chromium Code Reviews| Index: vm/unit_test.cc |
| =================================================================== |
| --- vm/unit_test.cc (revision 1595) |
| +++ vm/unit_test.cc (working copy) |
| @@ -48,11 +48,39 @@ |
| } |
| +static Dart_Handle LibraryTagHandler(Dart_LibraryTag tag, |
| + Dart_Handle library, |
| + Dart_Handle url) { |
| + if (!Dart_IsLibrary(library)) { |
| + return Dart_Error("not a library"); |
| + } |
| + if (!Dart_IsString8(url)) { |
| + return Dart_Error("url is not a string"); |
| + } |
| + const char* url_chars = NULL; |
| + Dart_Handle result = Dart_StringToCString(url, &url_chars); |
| + if (Dart_IsError(result)) { |
| + return Dart_Error("accessing url characters failed"); |
| + } |
| + static const char* kDartScheme = "dart:"; |
| + static const intptr_t kDartSchemeLen = strlen(kDartScheme); |
| + // If the URL starts with "dart:" then it is not modified as it will be |
| + // handled by the VM internally. |
| + if (strncmp(url_chars, kDartScheme, kDartSchemeLen) == 0) { |
| + if (tag == kCanonicalizeUrl) { |
| + return Dart_NewString(url_chars); |
|
Ivan Posva
2011/11/17 19:35:06
Why don't you just return the incoming url?
siva
2011/11/17 20:00:17
Done.
|
| + } |
| + return Dart_Error("unexpected tag encountered %d", tag); |
| + } |
| + return Dart_Error("unsupported url encountered %s", url_chars); |
| +} |
| + |
| + |
| Dart_Handle TestCase::LoadTestScript(const char* script, |
| Dart_NativeEntryResolver resolver) { |
| Dart_Handle url = Dart_NewString(TestCase::url()); |
| Dart_Handle source = Dart_NewString(script); |
| - Dart_Handle lib = Dart_LoadScript(url, source, NULL); |
| + Dart_Handle lib = Dart_LoadScript(url, source, LibraryTagHandler); |
| ASSERT(!Dart_IsError(lib)); |
| Dart_Handle result = Dart_SetNativeResolver(lib, resolver); |
| ASSERT(!Dart_IsError(result)); |