Commit 5c043568 authored by Yuki Shiino's avatar Yuki Shiino Committed by Commit Bot

bind-gen: Fix the execution context for reporting to the current one

Changes the execution context for reporting / measurements from
the receiver object's execution context to the current context's
execution context.

Bug: 839389
Change-Id: Iab09ad3a27df7038d56b9661343dead1d41cb499
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2352949Reviewed-by: default avatarHitoshi Yoshida <peria@chromium.org>
Commit-Queue: Yuki Shiino <yukishiino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#797591}
parent 3f750785
...@@ -316,8 +316,21 @@ def bind_callback_local_vars(code_node, cg_context): ...@@ -316,8 +316,21 @@ def bind_callback_local_vars(code_node, cg_context):
local_vars.append(S("script_state", _format(pattern, _1=_1))) local_vars.append(S("script_state", _format(pattern, _1=_1)))
# execution_context # execution_context
node = S("execution_context", ("ExecutionContext* ${execution_context} = " pattern = "ExecutionContext* ${execution_context} = {_1};"
"ExecutionContext::From(${script_state});")) _1 = ("${receiver_execution_context}"
if is_receiver_context else "${current_execution_context}")
local_vars.append(S("execution_context", _format(pattern, _1=_1)))
node = S("current_execution_context",
("ExecutionContext* ${current_execution_context} = "
"ExecutionContext::From(${current_script_state});"))
node.accumulate(
CodeGenAccumulator.require_include_headers([
"third_party/blink/renderer/core/execution_context/execution_context.h"
]))
local_vars.append(node)
node = S("receiver_execution_context",
("ExecutionContext* ${receiver_execution_context} = "
"ExecutionContext::From(${receiver_script_state});"))
node.accumulate( node.accumulate(
CodeGenAccumulator.require_include_headers([ CodeGenAccumulator.require_include_headers([
"third_party/blink/renderer/core/execution_context/execution_context.h" "third_party/blink/renderer/core/execution_context/execution_context.h"
...@@ -329,7 +342,7 @@ def bind_callback_local_vars(code_node, cg_context): ...@@ -329,7 +342,7 @@ def bind_callback_local_vars(code_node, cg_context):
if is_receiver_context: if is_receiver_context:
_1 = "bindings::ExecutionContextFromV8Wrappable(${blink_receiver})" _1 = "bindings::ExecutionContextFromV8Wrappable(${blink_receiver})"
else: else:
_1 = "${execution_context}" # of the current context _1 = "${current_execution_context}"
text = _format(pattern, _1=_1) text = _format(pattern, _1=_1)
local_vars.append(S("execution_context_of_document_tree", text)) local_vars.append(S("execution_context_of_document_tree", text))
...@@ -865,8 +878,8 @@ def make_check_security_of_return_value(cg_context): ...@@ -865,8 +878,8 @@ def make_check_security_of_return_value(cg_context):
"WebFeature::{}", "WebFeature::{}",
name_style.constant("CrossOrigin", cg_context.class_like.identifier, name_style.constant("CrossOrigin", cg_context.class_like.identifier,
cg_context.property_.identifier)) cg_context.property_.identifier))
use_counter = _format("UseCounter::Count(${execution_context}, {});", use_counter = _format(
web_feature) "UseCounter::Count(${current_execution_context}, {});", web_feature)
cond = T("!BindingSecurity::ShouldAllowAccessTo(" cond = T("!BindingSecurity::ShouldAllowAccessTo("
"ToLocalDOMWindow(${current_context}), ${return_value}, " "ToLocalDOMWindow(${current_context}), ${return_value}, "
"BindingSecurity::ErrorReportOption::kDoNotReport)") "BindingSecurity::ErrorReportOption::kDoNotReport)")
...@@ -1236,7 +1249,7 @@ def make_report_deprecate_as(cg_context): ...@@ -1236,7 +1249,7 @@ def make_report_deprecate_as(cg_context):
pattern = ("// [DeprecateAs]\n" pattern = ("// [DeprecateAs]\n"
"Deprecation::CountDeprecation(" "Deprecation::CountDeprecation("
"${execution_context}, WebFeature::k{_1});") "${current_execution_context}, WebFeature::k{_1});")
_1 = name _1 = name
node = TextNode(_format(pattern, _1=_1)) node = TextNode(_format(pattern, _1=_1))
node.accumulate( node.accumulate(
...@@ -1292,13 +1305,15 @@ def make_report_high_entropy(cg_context): ...@@ -1292,13 +1305,15 @@ def make_report_high_entropy(cg_context):
if ext_attrs.value_of("HighEntropy") == "Direct": if ext_attrs.value_of("HighEntropy") == "Direct":
text = _format( text = _format(
"// [HighEntropy=Direct]\n" "// [HighEntropy=Direct]\n"
"Dactyloscoper::RecordDirectSurface" "Dactyloscoper::RecordDirectSurface("
"(${execution_context}, {measure_constant}, ${return_value});", "${current_execution_context}, {measure_constant}, "
"${return_value});",
measure_constant=_make_measure_web_feature_constant(cg_context)) measure_constant=_make_measure_web_feature_constant(cg_context))
else: else:
text = _format( text = _format(
"// [HighEntropy]\n" "// [HighEntropy]\n"
"Dactyloscoper::Record(${execution_context}, {measure_constant});", "Dactyloscoper::Record("
"${current_execution_context}, {measure_constant});",
measure_constant=_make_measure_web_feature_constant(cg_context)) measure_constant=_make_measure_web_feature_constant(cg_context))
node = TextNode(text) node = TextNode(text)
node.accumulate( node.accumulate(
...@@ -1317,7 +1332,7 @@ def make_report_measure_as(cg_context): ...@@ -1317,7 +1332,7 @@ def make_report_measure_as(cg_context):
text = _format( text = _format(
"// [Measure], [MeasureAs]\n" "// [Measure], [MeasureAs]\n"
"UseCounter::Count(${execution_context}, {measure_constant});", "UseCounter::Count(${current_execution_context}, {measure_constant});",
measure_constant=_make_measure_web_feature_constant(cg_context)) measure_constant=_make_measure_web_feature_constant(cg_context))
node = TextNode(text) node = TextNode(text)
node.accumulate( node.accumulate(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment