From 63c52e75d0a4de04463b9f569ed04056966f1c1b Mon Sep 17 00:00:00 2001 From: caozhengfei Date: Mon, 26 May 2025 16:07:26 +0800 Subject: [PATCH] weba11y_0526 Signed-off-by: caozhengfei --- .../core/components_ng/pattern/web/web_pattern.cpp | 10 ++++++++++ .../core/pattern/web/web_pattern_part_one_test.cpp | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/frameworks/core/components_ng/pattern/web/web_pattern.cpp b/frameworks/core/components_ng/pattern/web/web_pattern.cpp index ee1f7ab7998..7cae7db4c64 100644 --- a/frameworks/core/components_ng/pattern/web/web_pattern.cpp +++ b/frameworks/core/components_ng/pattern/web/web_pattern.cpp @@ -805,6 +805,16 @@ void WebPattern::OnDetachFromMainTree() isAttachedToMainTree_ = false; // report component is in background. delegate_->OnRenderToBackground(); + + auto host = GetHost(); + CHECK_NULL_VOID(host); + auto pipelineContext = host->GetContext(); + CHECK_NULL_VOID(pipelineContext); + auto frontend = pipelineContext->GetFrontend(); + CHECK_NULL_VOID(frontend); + auto accessibilityManager = frontend->GetAccessibilityManager(); + CHECK_NULL_VOID(accessibilityManager); + accessibilityManager->ReleasePageEvent(host, true, true); } void WebPattern::OnAttachToFrameNode() diff --git a/test/unittest/core/pattern/web/web_pattern_part_one_test.cpp b/test/unittest/core/pattern/web/web_pattern_part_one_test.cpp index 7f2f0fc79e9..27adecafac1 100644 --- a/test/unittest/core/pattern/web/web_pattern_part_one_test.cpp +++ b/test/unittest/core/pattern/web/web_pattern_part_one_test.cpp @@ -471,7 +471,8 @@ HWTEST_F(WebPatternPartOneTest, OnDetachFromMainTree_001, TestSize.Level1) ASSERT_NE(webPattern, nullptr); webPattern->OnModifyDone(); ASSERT_NE(webPattern->delegate_, nullptr); - + auto host = webPattern->GetHost(); + EXPECT_NE(host, nullptr); webPattern->OnDetachFromMainTree(); ASSERT_NE(webPattern->delegate_, nullptr); #endif -- Gitee