<!doctype html>
<html lang="en">

<head>
  <!-- Import style -->
  <link rel="stylesheet" href="../index.css" />
  <link rel="stylesheet" href="../prettify.css" />
  <!-- Import Vue 3 -->
  <script src="../vue.global.prod.js"></script>
  <!-- Import component library -->
  <script src="../index.full.min.js"></script>
  <script src="../prettify.js"></script>
  <meta charset="UTF-8">
  <title>Coverage</title>
</head>

<body>
  <div id="app" class="common-layout">
    <el-container>
      <el-header>
        <el-row :gutter="10">
          <el-col :span="5">
            <el-space :size="size" spacer="">
              <div><el-text class="mx-1 ">
                  <el-link type="primary" :href="relativeHome">
                    <h2>&lt;</h2>
                  </el-link>
                </el-text></div>
              <div><el-text class="mx-1 "><h2>{{title}}</h2></el-text></div>
              <div><el-text class="mx-1 "
                  type="info"></el-text></div>
            </el-space>
          </el-col>
          <el-col :span="3">
            <el-space :size="size" spacer="">
              <div><el-text class="mx-1 ">
                  <h2>{{file.summary.functions.pct}}%</h2>
                </el-text></div>
              <div><el-text class="mx-1 ">Functions</el-text></div>
              <div><el-text class="mx-1 "
                  type="info">{{file.summary.functions.covered}}/{{file.summary.functions.total}}</el-text></div>
            </el-space>
          </el-col>
          <el-col :span="3">
            <el-space :size="size" spacer="">
              <div><el-text class="mx-1 ">
                  <h2>{{file.summary.branches.pct}}%</h2>
                </el-text></div>
              <div><el-text class="mx-1 ">Branches</el-text></div>
              <div><el-text class="mx-1 "
                  type="info">{{file.summary.branches.covered}}/{{file.summary.branches.total}}</el-text></div>
            </el-space>
          </el-col>
          <el-col :span="3">
            <el-space :size="size" spacer="">
              <div><el-text class="mx-1 ">
                  <h2>{{file.summary.lines.pct}}%</h2>
                </el-text></div>
              <div><el-text class="mx-1 ">Lines</el-text></div>
              <div><el-text class="mx-1 "
                  type="info">{{file.summary.lines.covered}}/{{file.summary.lines.total}}</el-text></div>
            </el-space>
          </el-col>
        </el-row>
        <el-divider />
      </el-header>
      <el-main>
        <el-row>
        </el-row>
        <pre>
          <table class="coverage">
            <tr>
              <td class="line-count quiet">
                <pre class="prettyprint lang-js">
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-no">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
                </pre>
        </td>
        <td class="text">
          <pre class="prettyprint linenums lang-js">
import webview from &#39;@ohos.web.webview&#39;; 
 
/** 
 * Cookie 管理辅助类。 
 * 
 * 在 SDK 加载第一个 Web 组件之前调用 `configure()` 一次以确保 Cookie 持久化能力开启。 
 */ 
export class CookieManagerHelper { 
  private static configured: boolean = false; 
 
  /** 全局配置 Cookie 策略，多次调用幂等。 */ 
  public static configure(): void { 
    if (CookieManagerHelper.configured) { 
      return; 
    } 
    try { 
      webview.WebCookieManager.putAcceptCookieEnabled(true); 
    } catch (_e) { 
      // ignore 
    } 
    CookieManagerHelper.configured = true; 
  } 
 
  /** 
   * 拉取目标 URL 的 Cookie 字符串(用于下载请求头注入等场景)。 
   * 
   * @param url 目标 URL 
   * @returns Cookie 字符串(`a=b; c=d` 形式),无 Cookie 返回空串 
   */ 
  public static fetchCookieFor(url: string): string { 
    if (url === null || url === undefined || url.length === 0) { 
      return &#39;&#39;; 
    } 
    try { 
      const cookie: string = webview.WebCookieManager.fetchCookieSync(url); 
      return cookie === null || cookie === undefined ? &#39;&#39; : cookie; 
    } catch (_e) { 
      return &#39;&#39;; 
    } 
  } 
 
  /** 
   * 持久化所有内存中的 Cookie 到磁盘。建议在容器关闭前调用。 
   */ 
  public static save(): void { 
    try { 
      webview.WebCookieManager.saveCookieAsync(); 
    } catch (_e) { 
      // 容错忽略 
    } 
  } 
 
  // ArkTS 类禁止实例化 
  private constructor() {} 
} 

              </pre>
        </td>
        </tr>
        </table>
        </pre>
      </el-main>
      <el-footer align="middle" class="footer">
        Code coverage generated by <el-link href="https://github.com/SMAT-Lab/bjc" type="primary"
          target="_blank">bjc</el-link> at {{date}}
      </el-footer>
    </el-container>
  </div>
</body>

<script>
  const App = {
    data() {
      return {"date":"Fri Jul 31 2026 16:52:24 GMT+0800 (China Standard Time)","file":{"version":"bjc v1.0.0","versionCode":10000,"path":"/Users/qinzhiqiang/Git/frontend/h5-in-app-integration/harmonyos-arkts/tencentqianwebview/src/main/ets/internal/CookieManagerHelper.ets","hash":"c99d14c39188a2a0a4e71a3dabebe775a6d2d9b6d040089a8b80031e7bedf46d","lineCnt":56,"count":0,"projectPath":"/Users/qinzhiqiang/Git/frontend/h5-in-app-integration/harmonyos-arkts","functions":[{"name":"CookieManagerHelper.configure","count":0,"regions":[{"startLoc":{"line":12,"col":3},"endLoc":{"line":22,"col":4},"count":0,"ignored":0},{"startLoc":{"line":13,"col":41},"endLoc":{"line":15,"col":6},"count":0,"ignored":0},{"startLoc":{"line":16,"col":9},"endLoc":{"line":18,"col":6},"count":0,"ignored":0},{"startLoc":{"line":18,"col":7},"endLoc":{"line":20,"col":6},"count":0,"ignored":0},{"startLoc":{"line":21,"col":5},"endLoc":{"line":22,"col":4},"count":0,"ignored":0}],"branches":[{"startLoc":{"line":13,"col":9},"endLoc":{"line":13,"col":39},"trueCount":0,"falseCount":0,"group":[],"ignored":0}],"ignored":0,"index":0},{"name":"CookieManagerHelper.fetchCookieFor","count":0,"regions":[{"startLoc":{"line":30,"col":3},"endLoc":{"line":40,"col":4},"count":0,"ignored":0},{"startLoc":{"line":34,"col":9},"endLoc":{"line":37,"col":6},"count":0,"ignored":0},{"startLoc":{"line":31,"col":64},"endLoc":{"line":33,"col":6},"count":0,"ignored":0},{"startLoc":{"line":37,"col":7},"endLoc":{"line":39,"col":6},"count":0,"ignored":0}],"branches":[{"startLoc":{"line":31,"col":9},"endLoc":{"line":31,"col":62},"trueCount":0,"falseCount":0,"group":[],"ignored":0},{"startLoc":{"line":36,"col":14},"endLoc":{"line":36,"col":67},"trueCount":0,"falseCount":0,"group":[],"ignored":0}],"ignored":0,"index":1},{"name":"CookieManagerHelper.save","count":0,"regions":[{"startLoc":{"line":45,"col":3},"endLoc":{"line":51,"col":4},"count":0,"ignored":0},{"startLoc":{"line":46,"col":9},"endLoc":{"line":48,"col":6},"count":0,"ignored":0},{"startLoc":{"line":48,"col":7},"endLoc":{"line":50,"col":6},"count":0,"ignored":0}],"branches":[],"ignored":0,"index":2},{"name":"CookieManagerHelper.constructor","count":0,"regions":[{"startLoc":{"line":54,"col":3},"endLoc":{"line":54,"col":27},"count":0,"ignored":0}],"branches":[],"ignored":0,"index":3}],"exeLine":{"0":1,"1":8,"2":9,"3":12,"4":13,"5":14,"6":16,"7":17,"8":18,"9":21,"10":30,"11":31,"12":32,"13":34,"14":35,"15":36,"16":37,"17":38,"18":45,"19":46,"20":47,"21":48,"22":54},"summary":{"lines":{"total":20,"covered":0,"pct":0,"executedLineCount":[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,0,0,-1,0,0,0,-1,-1,0,-1,-1,-1,-1,-1,-1,-1,-1,0,0,0,-1,0,0,0,0,0,-1,-1,-1,-1,-1,-1,0,0,0,0,-1,-1,-1,-1,-1,0,-1,-1]},"functions":{"total":4,"covered":0,"pct":0},"branches":{"total":6,"covered":0,"pct":0}}},"title":"CookieManagerHelper.ets.html","relativeHome":"../index.html"};
    }
  };

  const app = Vue.createApp(App);
  app.use(ElementPlus);
  app.mount("#app");

  window.onload = function () {
    prettyPrint();
  }
</script>

<style scoped>
  table.coverage {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0 0 0;
    padding: 0;
  }

  table.coverage td {
    margin: 0;
    padding: 0;
    vertical-align: top;
  }

  table.coverage td.line-count {
    width: 12%;
    text-align: right;
    padding: 0 5px 0 20px;
  }

  table.coverage td.line-coverage {
    text-align: right;
    padding-right: 10px;
    min-width: 20px;
  }

  table.coverage td span.cline-any {
    display: inline-block;
    padding: 0 5px;
    width: 100%;
    height: 18px;
  }

  .low,
  .cline-no {
    background: #FCE1E5
  }

  .high,
  .cline-yes {
    background: rgb(230, 245, 208)
  }

  span.cline-neutral {
    background: #eaeaea;
  }

  pre.prettyprint {
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .el-main {
    box-sizing: border-box;
    display: block;
    flex: 1;
    flex-basis: auto;
    overflow: auto;
    padding: var(--el-main-padding)
  }

  .el-container {
    min-height: 100vh;
    height: 100%;
  }

  .footer {
    font-size: small;
  }

  .el-row {
    margin-bottom: 20px;
  }

  .el-row:last-child {
    margin-bottom: 0;
  }

  .el-col {
    border-radius: 4px;
  }

  .green {
    color: var(--el-color-success);
  }

  .red {
    color: var(--el-color-error);
  }

  .linenums li {
    height: 18px;
    line-height: 18px;
  }

  li.L0,
  li.L1,
  li.L2,
  li.L3,
  li.L5,
  li.L6,
  li.L7,
  li.L8 {
    list-style-type: decimal
  }

  .el-col-5 {
    max-width: 100%;
  }

  .el-col-3 {
    max-width: 100%;
  }

</style>

</html>