@@ -63,6 +63,10 @@ using v8::UnboundModuleScript;
63
63
using v8::Undefined;
64
64
using v8::Value;
65
65
66
+ inline bool DataIsString (Local<Data> data) {
67
+ return data->IsValue () && data.As <Value>()->IsString ();
68
+ }
69
+
66
70
void ModuleCacheKey::MemoryInfo (MemoryTracker* tracker) const {
67
71
tracker->TrackField (" specifier" , specifier);
68
72
tracker->TrackField (" import_attributes" , import_attributes);
@@ -83,6 +87,9 @@ ModuleCacheKey ModuleCacheKey::From(Local<Context> context,
83
87
84
88
for (int i = 0 ; i < import_attributes->Length ();
85
89
i += elements_per_attribute) {
90
+ DCHECK (DataIsString (import_attributes->Get (context, i)));
91
+ DCHECK (DataIsString (import_attributes->Get (context, i + 1 )));
92
+
86
93
Local<String> v8_key = import_attributes->Get (context, i).As <String>();
87
94
Local<String> v8_value =
88
95
import_attributes->Get (context, i + 1 ).As <String>();
@@ -488,9 +495,12 @@ static Local<Object> createImportAttributesContainer(
488
495
LocalVector<Value> values (isolate, num_attributes);
489
496
490
497
for (int i = 0 ; i < raw_attributes->Length (); i += elements_per_attribute) {
498
+ DCHECK (DataIsString (raw_attributes->Get (context, i)));
499
+ DCHECK (DataIsString (raw_attributes->Get (context, i + 1 )));
500
+
491
501
int idx = i / elements_per_attribute;
492
- names[idx] = raw_attributes->Get (realm->context (), i).As <Name >();
493
- values[idx] = raw_attributes->Get (realm->context (), i + 1 ).As <Value >();
502
+ names[idx] = raw_attributes->Get (realm->context (), i).As <String >();
503
+ values[idx] = raw_attributes->Get (realm->context (), i + 1 ).As <String >();
494
504
}
495
505
496
506
Local<Object> attributes = Object::New (
@@ -507,6 +517,7 @@ static Local<Array> createModuleRequestsContainer(
507
517
LocalVector<Value> requests (isolate, raw_requests->Length ());
508
518
509
519
for (int i = 0 ; i < raw_requests->Length (); i++) {
520
+ DCHECK (raw_requests->Get (context, i)->IsModuleRequest ());
510
521
Local<ModuleRequest> module_request =
511
522
raw_requests->Get (realm->context (), i).As <ModuleRequest>();
512
523
0 commit comments