提交 64ecf621 编写于 作者: A Adam Barth

Add a flag to sky_viewer to enable checked mode

This flag will let clients who use release builds enable checked mode.

Fixes #22
上级 005db969
......@@ -16,11 +16,15 @@ RuntimeFlags flags;
// Load the viewer in testing mode so we can dump pixels.
const char kTesting[] = "--testing";
// Instruct the DartVM to report type errors.
const char kEnableCheckedMode[] = "--enable-checked-mode";
} // namespace
void RuntimeFlags::Initialize(mojo::ApplicationImpl* app) {
DCHECK(!initialized);
flags.testing_ = app->HasArg(kTesting);
flags.enable_checked_mode_ = app->HasArg(kEnableCheckedMode);
initialized = true;
}
......
......@@ -17,9 +17,11 @@ class RuntimeFlags {
static const RuntimeFlags& Get();
bool testing() const { return testing_; }
bool enable_checked_mode() const { return enable_checked_mode_; }
private:
bool testing_;
bool testing_ = false;
bool enable_checked_mode_ = false;
};
} // namespace sky
......
......@@ -37,6 +37,8 @@ class Viewer : public mojo::ApplicationDelegate,
blink::WebRuntimeFeatures::enableObservatory(
!RuntimeFlags::Get().testing());
blink::WebRuntimeFeatures::enableDartCheckedMode(
RuntimeFlags::Get().enable_checked_mode());
platform_impl_.reset(new PlatformImpl());
blink::initialize(platform_impl_.get());
......
......@@ -75,15 +75,16 @@ void CreateEmptyRootLibraryIfNeeded() {
static const char* kDartArgs[] = {
"--enable_mirrors=false",
#if ENABLE(DART_STRICT)
"--enable_asserts",
"--enable_type_checks",
"--error_on_bad_type",
"--error_on_bad_override",
#if WTF_OS_IOS || WTF_OS_MACOSX
"--no-profile"
#endif
#endif
};
static const char* kDartCheckedModeArgs[] = {
"--enable_asserts",
"--enable_type_checks",
"--error_on_bad_type",
"--error_on_bad_override",
};
void UnhandledExceptionCallback(Dart_Handle error) {
......@@ -172,7 +173,17 @@ Dart_Isolate IsolateCreateCallback(const char* script_uri,
void InitDartVM() {
dart::bin::BootstrapDartIo();
CHECK(Dart_SetVMFlags(arraysize(kDartArgs), kDartArgs));
bool enable_checked_mode = RuntimeEnabledFeatures::dartCheckedModeEnabled();
#if ENABLE(DART_STRICT)
enable_checked_mode = true;
#endif
Vector<const char*> args;
args.append(kDartArgs, arraysize(kDartArgs));
if (enable_checked_mode)
args.append(kDartCheckedModeArgs, arraysize(kDartCheckedModeArgs));
CHECK(Dart_SetVMFlags(args.size(), args.data()));
// This should be called before calling Dart_Initialize.
DartDebugger::InitDebugger();
CHECK(Dart_Initialize(kDartVmIsolateSnapshotBuffer,
......
......@@ -120,3 +120,4 @@ PseudoClassesInMatchingCriteriaInAuthorShadowTrees status=test
CredentialManager status=test
Observatory status=stable
DartCheckedMode
......@@ -94,6 +94,8 @@ public:
BLINK_EXPORT static void enableObservatory(bool);
BLINK_EXPORT static void enableDartCheckedMode(bool);
private:
WebRuntimeFeatures();
};
......
......@@ -175,4 +175,9 @@ void WebRuntimeFeatures::enableObservatory(bool enable)
RuntimeEnabledFeatures::setObservatoryEnabled(enable);
}
void WebRuntimeFeatures::enableDartCheckedMode(bool enable)
{
RuntimeEnabledFeatures::setDartCheckedModeEnabled(enable);
}
} // namespace blink
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册