{
  "format": 3,
  "id": "1.2",
  "title": "Logical browser, context, page and frame relationships",
  "layers": {
    "server": {
      "label": "Server"
    },
    "browser": {
      "label": "Browser"
    },
    "page": {
      "label": "Page"
    },
    "client": {
      "label": "Client"
    },
    "fail": {
      "label": "Fail"
    }
  },
  "lanes": {
    "objects": {
      "label": "LOGICAL OBJECTS · NOT OS PROCESSES",
      "layer": "server"
    }
  },
  "frames": {},
  "nodes": {
    "browser": {
      "label": "Browser",
      "layer": "server",
      "lane": "objects"
    },
    "contextA": {
      "label": "Context A · ID A",
      "layer": "browser",
      "lane": "objects"
    },
    "pageA": {
      "label": "Page A",
      "layer": "server",
      "lane": "objects"
    },
    "mainA": {
      "label": "main frame A",
      "layer": "page",
      "lane": "objects"
    },
    "childA": {
      "label": "child iframe A",
      "layer": "page",
      "lane": "objects"
    },
    "nestedA": {
      "label": "nested iframe A",
      "layer": "page",
      "lane": "objects"
    },
    "contextB": {
      "label": "Context B · ID B",
      "layer": "browser",
      "lane": "objects"
    },
    "pageB": {
      "label": "Page B",
      "layer": "server",
      "lane": "objects"
    },
    "mainB": {
      "label": "main frame B",
      "layer": "page",
      "lane": "objects"
    },
    "childB": {
      "label": "child iframe B",
      "layer": "page",
      "lane": "objects"
    },
    "nestedB": {
      "label": "nested iframe B",
      "layer": "page",
      "lane": "objects"
    },
    "owned": {
      "label": "owned context",
      "layer": "browser",
      "lane": "objects"
    },
    "shortcut": {
      "label": "shortcut page",
      "layer": "server",
      "lane": "objects"
    },
    "call": {
      "label": "Page A call",
      "layer": "client",
      "lane": "objects"
    },
    "error": {
      "label": "call fails",
      "layer": "fail",
      "lane": "objects",
      "fail": true
    }
  },
  "edges": {
    "browserA": {
      "from": "browser",
      "to": "contextA",
      "label": "holds"
    },
    "contextA": {
      "from": "contextA",
      "to": "pageA",
      "label": "holds"
    },
    "pageA": {
      "from": "pageA",
      "to": "mainA",
      "label": "contains"
    },
    "mainA": {
      "from": "mainA",
      "to": "childA",
      "label": "child"
    },
    "childA": {
      "from": "childA",
      "to": "nestedA",
      "label": "child"
    },
    "browserB": {
      "from": "browser",
      "to": "contextB",
      "label": "holds"
    },
    "contextB": {
      "from": "contextB",
      "to": "pageB",
      "label": "holds"
    },
    "pageB": {
      "from": "pageB",
      "to": "mainB",
      "label": "contains"
    },
    "mainB": {
      "from": "mainB",
      "to": "childB",
      "label": "child"
    },
    "childB": {
      "from": "childB",
      "to": "nestedB",
      "label": "child"
    },
    "owns": {
      "from": "shortcut",
      "to": "owned",
      "label": "owns"
    },
    "closed": {
      "from": "call",
      "to": "error",
      "label": "fails"
    }
  },
  "scenarios": [
    {
      "id": "how",
      "label": "Browser, context, page, frame",
      "display": {
        "counterLabel": false,
        "edges": "progressive",
        "edgeBadges": true,
        "nodeBadges": false,
        "log": "incremental"
      },
      "steps": [
        {
          "id": "a-browser-holds-contexts",
          "title": "A browser holds contexts",
          "text": "A browser holds contexts. This map shows logical object relationships; each Context, Page or Frame is not a new OS process.",
          "show": [
            "browser",
            "contextA",
            "contextB"
          ],
          "current": [
            "browser"
          ],
          "edges": [
            "browserA",
            "browserB"
          ],
          "defs": [
            "browser"
          ],
          "log": [],
          "sources": [
            {
              "label": "browser.ts:116-123",
              "url": "https://github.com/microsoft/playwright/blob/v1.65.0/packages/playwright-core/src/server/browser.ts#L116-L123"
            },
            {
              "label": "page.ts:207-217",
              "url": "https://github.com/microsoft/playwright/blob/v1.65.0/packages/playwright-core/src/server/page.ts#L207-L217"
            },
            {
              "label": "frames.ts:151-164",
              "url": "https://github.com/microsoft/playwright/blob/v1.65.0/packages/playwright-core/src/server/frames.ts#L151-L164"
            }
          ],
          "deeper": [
            {
              "title": "0.1 API calls leave from Node, page calls from the browser",
              "href": "/0-anatomy/0-1-anatomy-of-a-test/"
            },
            {
              "title": "1.1 A failed call comes back with its name and its call log",
              "href": "/1-messages/1-1-one-call-two-processes/"
            },
            {
              "title": "4.2 Built on demand, torn down in reverse",
              "href": "/4-runner/4-2-custom-fixtures/"
            }
          ]
        },
        {
          "id": "a-context-holds-pages",
          "title": "A context holds pages",
          "text": "A server page belongs to a browser context. Context A and Context B each hold a page.",
          "show": [
            "pageA",
            "pageB"
          ],
          "current": [
            "pageA",
            "pageB"
          ],
          "edges": [
            "contextA",
            "contextB"
          ],
          "defs": [
            "context"
          ],
          "log": [],
          "sources": [
            {
              "label": "page.ts:207-217",
              "url": "https://github.com/microsoft/playwright/blob/v1.65.0/packages/playwright-core/src/server/page.ts#L207-L217"
            },
            {
              "label": "crBrowser.ts:128-136",
              "url": "https://github.com/microsoft/playwright/blob/v1.65.0/packages/playwright-core/src/server/chromium/crBrowser.ts#L128-L136"
            },
            {
              "label": "browsercontext-basic.spec.ts:118-153",
              "url": "https://github.com/microsoft/playwright/blob/v1.65.0/tests/library/browsercontext-basic.spec.ts#L118-L153"
            }
          ],
          "deeper": [
            {
              "title": "0.1 API calls leave from Node, page calls from the browser",
              "href": "/0-anatomy/0-1-anatomy-of-a-test/"
            },
            {
              "title": "1.1 A failed call comes back with its name and its call log",
              "href": "/1-messages/1-1-one-call-two-processes/"
            },
            {
              "title": "4.2 Built on demand, torn down in reverse",
              "href": "/4-runner/4-2-custom-fixtures/"
            }
          ]
        },
        {
          "id": "each-page-has-a-main-frame",
          "title": "Each page has a main frame",
          "text": "Each page has one main frame.",
          "show": [
            "mainA",
            "mainB"
          ],
          "current": [
            "mainA",
            "mainB"
          ],
          "edges": [
            "pageA",
            "pageB"
          ],
          "defs": [
            "page"
          ],
          "log": [],
          "sources": [
            {
              "label": "frames.ts:151-164",
              "url": "https://github.com/microsoft/playwright/blob/v1.65.0/packages/playwright-core/src/server/frames.ts#L151-L164"
            },
            {
              "label": "pageDispatcher.ts:88-100",
              "url": "https://github.com/microsoft/playwright/blob/v1.65.0/packages/playwright-core/src/server/dispatchers/pageDispatcher.ts#L88-L100"
            }
          ],
          "deeper": [
            {
              "title": "0.1 API calls leave from Node, page calls from the browser",
              "href": "/0-anatomy/0-1-anatomy-of-a-test/"
            },
            {
              "title": "1.1 A failed call comes back with its name and its call log",
              "href": "/1-messages/1-1-one-call-two-processes/"
            },
            {
              "title": "4.2 Built on demand, torn down in reverse",
              "href": "/4-runner/4-2-custom-fixtures/"
            }
          ]
        },
        {
          "id": "iframes-add-child-frames",
          "title": "Iframes add child frames",
          "text": "Every iframe adds a child frame under the main frame. Child frames can have their own children.",
          "show": [
            "childA",
            "childB",
            "nestedA",
            "nestedB"
          ],
          "current": [
            "childA",
            "nestedA"
          ],
          "edges": [
            "mainA",
            "mainB",
            "childA",
            "childB"
          ],
          "defs": [
            "frame"
          ],
          "log": [],
          "sources": [
            {
              "label": "frames.ts:151-164",
              "url": "https://github.com/microsoft/playwright/blob/v1.65.0/packages/playwright-core/src/server/frames.ts#L151-L164"
            },
            {
              "label": "frame.ts:76-82",
              "url": "https://github.com/microsoft/playwright/blob/v1.65.0/packages/playwright-core/src/client/frame.ts#L76-L82"
            }
          ],
          "deeper": [
            {
              "title": "0.1 API calls leave from Node, page calls from the browser",
              "href": "/0-anatomy/0-1-anatomy-of-a-test/"
            },
            {
              "title": "1.1 A failed call comes back with its name and its call log",
              "href": "/1-messages/1-1-one-call-two-processes/"
            },
            {
              "title": "4.2 Built on demand, torn down in reverse",
              "href": "/4-runner/4-2-custom-fixtures/"
            }
          ]
        },
        {
          "id": "contexts-keep-state-apart",
          "title": "Contexts keep state apart",
          "text": "Two contexts opening the same site keep separate cookies and local storage. The IDs and state labels on this spread are examples.",
          "show": [],
          "current": [
            "contextA",
            "contextB"
          ],
          "edges": [],
          "defs": [
            "isolation",
            "state"
          ],
          "code": "users",
          "log": [],
          "sources": [
            {
              "label": "browsercontext-basic.spec.ts:118-153",
              "url": "https://github.com/microsoft/playwright/blob/v1.65.0/tests/library/browsercontext-basic.spec.ts#L118-L153"
            },
            {
              "label": "crBrowser.ts:128-136",
              "url": "https://github.com/microsoft/playwright/blob/v1.65.0/packages/playwright-core/src/server/chromium/crBrowser.ts#L128-L136"
            },
            {
              "label": "crBrowser.ts:389-391",
              "url": "https://github.com/microsoft/playwright/blob/v1.65.0/packages/playwright-core/src/server/chromium/crBrowser.ts#L389-L391"
            },
            {
              "label": "crBrowser.ts:438-441",
              "url": "https://github.com/microsoft/playwright/blob/v1.65.0/packages/playwright-core/src/server/chromium/crBrowser.ts#L438-L441"
            }
          ],
          "deeper": [
            {
              "title": "0.1 API calls leave from Node, page calls from the browser",
              "href": "/0-anatomy/0-1-anatomy-of-a-test/"
            },
            {
              "title": "1.1 A failed call comes back with its name and its call log",
              "href": "/1-messages/1-1-one-call-two-processes/"
            },
            {
              "title": "4.2 Built on demand, torn down in reverse",
              "href": "/4-runner/4-2-custom-fixtures/"
            }
          ]
        },
        {
          "id": "chromium-assigns-a-context-id",
          "title": "Chromium assigns a context ID",
          "text": "Chromium creates each browser context with its own ID. Cookie reads and writes carry that ID.",
          "show": [],
          "current": [
            "contextA",
            "contextB"
          ],
          "edges": [],
          "defs": [
            "isolation"
          ],
          "code": "id",
          "log": [],
          "sources": [
            {
              "label": "crBrowser.ts:128-136",
              "url": "https://github.com/microsoft/playwright/blob/v1.65.0/packages/playwright-core/src/server/chromium/crBrowser.ts#L128-L136"
            },
            {
              "label": "crBrowser.ts:389-391",
              "url": "https://github.com/microsoft/playwright/blob/v1.65.0/packages/playwright-core/src/server/chromium/crBrowser.ts#L389-L391"
            },
            {
              "label": "crBrowser.ts:438-441",
              "url": "https://github.com/microsoft/playwright/blob/v1.65.0/packages/playwright-core/src/server/chromium/crBrowser.ts#L438-L441"
            },
            {
              "label": "browsercontext-basic.spec.ts:118-153",
              "url": "https://github.com/microsoft/playwright/blob/v1.65.0/tests/library/browsercontext-basic.spec.ts#L118-L153"
            }
          ],
          "deeper": [
            {
              "title": "0.1 API calls leave from Node, page calls from the browser",
              "href": "/0-anatomy/0-1-anatomy-of-a-test/"
            },
            {
              "title": "1.1 A failed call comes back with its name and its call log",
              "href": "/1-messages/1-1-one-call-two-processes/"
            },
            {
              "title": "4.2 Built on demand, torn down in reverse",
              "href": "/4-runner/4-2-custom-fixtures/"
            }
          ]
        },
        {
          "id": "closing-has-boundaries",
          "title": "Closing has boundaries",
          "text": "Closing an explicit context closes its pages; the other context stays available. Closing the browser closes every context.",
          "show": [],
          "current": [
            "browser",
            "contextA",
            "contextB"
          ],
          "edges": [
            "browserA",
            "browserB",
            "contextA",
            "contextB"
          ],
          "defs": [
            "closedA",
            "closedBoth"
          ],
          "log": [],
          "sources": [
            {
              "label": "class-browsercontext.md:596",
              "url": "https://github.com/microsoft/playwright/blob/v1.65.0/docs/src/api/class-browsercontext.md#L596"
            },
            {
              "label": "browsercontext-basic.spec.ts:24-33",
              "url": "https://github.com/microsoft/playwright/blob/v1.65.0/tests/library/browsercontext-basic.spec.ts#L24-L33"
            },
            {
              "label": "browser.ts:174-178",
              "url": "https://github.com/microsoft/playwright/blob/v1.65.0/packages/playwright-core/src/server/browser.ts#L174-L178"
            },
            {
              "label": "browserContext.ts:256-260",
              "url": "https://github.com/microsoft/playwright/blob/v1.65.0/packages/playwright-core/src/server/browserContext.ts#L256-L260"
            }
          ],
          "deeper": [
            {
              "title": "0.1 API calls leave from Node, page calls from the browser",
              "href": "/0-anatomy/0-1-anatomy-of-a-test/"
            },
            {
              "title": "1.1 A failed call comes back with its name and its call log",
              "href": "/1-messages/1-1-one-call-two-processes/"
            },
            {
              "title": "4.2 Built on demand, torn down in reverse",
              "href": "/4-runner/4-2-custom-fixtures/"
            }
          ]
        },
        {
          "id": "the-shortcut-owns-a-context",
          "title": "The shortcut owns a context",
          "text": "browser.newPage() creates a page and its own context. Closing that page also closes its owned context; an ordinary page.close() instead closes its page channel.",
          "show": [
            "owned",
            "shortcut"
          ],
          "current": [
            "owned",
            "shortcut"
          ],
          "edges": [
            "owns"
          ],
          "defs": [
            "shortcut",
            "ordinary",
            "target"
          ],
          "code": "close",
          "log": [],
          "sources": [
            {
              "label": "browser.ts:145-152",
              "url": "https://github.com/microsoft/playwright/blob/v1.65.0/packages/playwright-core/src/client/browser.ts#L145-L152"
            },
            {
              "label": "page.ts:709-719",
              "url": "https://github.com/microsoft/playwright/blob/v1.65.0/packages/playwright-core/src/client/page.ts#L709-L719"
            },
            {
              "label": "dispatcher.ts:315-318",
              "url": "https://github.com/microsoft/playwright/blob/v1.65.0/packages/playwright-core/src/server/dispatchers/dispatcher.ts#L315-L318"
            },
            {
              "label": "errors.ts:36-39",
              "url": "https://github.com/microsoft/playwright/blob/v1.65.0/packages/playwright-core/src/server/errors.ts#L36-L39"
            }
          ],
          "deeper": [
            {
              "title": "0.1 API calls leave from Node, page calls from the browser",
              "href": "/0-anatomy/0-1-anatomy-of-a-test/"
            },
            {
              "title": "1.1 A failed call comes back with its name and its call log",
              "href": "/1-messages/1-1-one-call-two-processes/"
            },
            {
              "title": "4.2 Built on demand, torn down in reverse",
              "href": "/4-runner/4-2-custom-fixtures/"
            }
          ]
        },
        {
          "id": "a-call-after-closing-fails",
          "title": "A call after closing fails",
          "text": "A call to a page whose server object is gone fails with Target page, context or browser has been closed. The message does not say which close ran.",
          "show": [
            "call",
            "error"
          ],
          "current": [
            "error"
          ],
          "edges": [
            "closed"
          ],
          "defs": [
            "target"
          ],
          "log": [],
          "sources": [
            {
              "label": "dispatcher.ts:315-318",
              "url": "https://github.com/microsoft/playwright/blob/v1.65.0/packages/playwright-core/src/server/dispatchers/dispatcher.ts#L315-L318"
            },
            {
              "label": "errors.ts:36-39",
              "url": "https://github.com/microsoft/playwright/blob/v1.65.0/packages/playwright-core/src/server/errors.ts#L36-L39"
            }
          ],
          "deeper": [
            {
              "title": "0.1 API calls leave from Node, page calls from the browser",
              "href": "/0-anatomy/0-1-anatomy-of-a-test/"
            },
            {
              "title": "1.1 A failed call comes back with its name and its call log",
              "href": "/1-messages/1-1-one-call-two-processes/"
            },
            {
              "title": "4.2 Built on demand, torn down in reverse",
              "href": "/4-runner/4-2-custom-fixtures/"
            }
          ]
        }
      ]
    },
    {
      "id": "roles",
      "label": "Two roles",
      "display": {
        "counterLabel": true,
        "edges": "all",
        "edgeBadges": false,
        "nodeBadges": true,
        "log": "incremental"
      },
      "whole": {
        "title": "Two contexts keep state apart",
        "text": "Both pages open the same example site."
      },
      "steps": [
        {
          "id": "a-browser-holds-two-contexts",
          "title": "A browser holds two contexts.",
          "text": "A browser holds two contexts. Both pages open the same example site.",
          "show": [
            "browser",
            "contextA",
            "pageA",
            "mainA",
            "childA",
            "nestedA",
            "contextB",
            "pageB",
            "mainB",
            "childB",
            "nestedB"
          ],
          "current": [
            "browser"
          ],
          "edges": [
            "browserA",
            "browserB"
          ],
          "defs": [
            "browser",
            "state"
          ],
          "log": [],
          "sources": [
            {
              "label": "browser.ts:116-123",
              "url": "https://github.com/microsoft/playwright/blob/v1.65.0/packages/playwright-core/src/server/browser.ts#L116-L123"
            },
            {
              "label": "crBrowser.ts:128-136",
              "url": "https://github.com/microsoft/playwright/blob/v1.65.0/packages/playwright-core/src/server/chromium/crBrowser.ts#L128-L136"
            },
            {
              "label": "browsercontext-basic.spec.ts:118-153",
              "url": "https://github.com/microsoft/playwright/blob/v1.65.0/tests/library/browsercontext-basic.spec.ts#L118-L153"
            }
          ],
          "deeper": [
            {
              "title": "0.1 API calls leave from Node, page calls from the browser",
              "href": "/0-anatomy/0-1-anatomy-of-a-test/"
            },
            {
              "title": "1.1 A failed call comes back with its name and its call log",
              "href": "/1-messages/1-1-one-call-two-processes/"
            },
            {
              "title": "4.2 Built on demand, torn down in reverse",
              "href": "/4-runner/4-2-custom-fixtures/"
            }
          ]
        },
        {
          "id": "each-page-contains-a-main-frame",
          "title": "Each page contains a main frame and child frames.",
          "text": "Each page contains a main frame and child frames.",
          "show": [],
          "current": [
            "mainA",
            "childA",
            "nestedA"
          ],
          "edges": [
            "contextA",
            "pageA",
            "mainA",
            "childA"
          ],
          "defs": [
            "page",
            "frame"
          ],
          "log": [],
          "sources": [
            {
              "label": "page.ts:207-217",
              "url": "https://github.com/microsoft/playwright/blob/v1.65.0/packages/playwright-core/src/server/page.ts#L207-L217"
            },
            {
              "label": "frames.ts:151-164",
              "url": "https://github.com/microsoft/playwright/blob/v1.65.0/packages/playwright-core/src/server/frames.ts#L151-L164"
            },
            {
              "label": "frame.ts:76-82",
              "url": "https://github.com/microsoft/playwright/blob/v1.65.0/packages/playwright-core/src/client/frame.ts#L76-L82"
            }
          ],
          "deeper": [
            {
              "title": "0.1 API calls leave from Node, page calls from the browser",
              "href": "/0-anatomy/0-1-anatomy-of-a-test/"
            },
            {
              "title": "1.1 A failed call comes back with its name and its call log",
              "href": "/1-messages/1-1-one-call-two-processes/"
            },
            {
              "title": "4.2 Built on demand, torn down in reverse",
              "href": "/4-runner/4-2-custom-fixtures/"
            }
          ]
        },
        {
          "id": "the-contexts-have-separate-cooki",
          "title": "The contexts have separate cookies and local storage.",
          "text": "The contexts have separate cookies and local storage.",
          "show": [],
          "current": [
            "contextA",
            "contextB"
          ],
          "edges": [],
          "defs": [
            "isolation",
            "state"
          ],
          "code": "users",
          "log": [],
          "sources": [
            {
              "label": "browsercontext-basic.spec.ts:118-153",
              "url": "https://github.com/microsoft/playwright/blob/v1.65.0/tests/library/browsercontext-basic.spec.ts#L118-L153"
            }
          ],
          "deeper": [
            {
              "title": "0.1 API calls leave from Node, page calls from the browser",
              "href": "/0-anatomy/0-1-anatomy-of-a-test/"
            },
            {
              "title": "1.1 A failed call comes back with its name and its call log",
              "href": "/1-messages/1-1-one-call-two-processes/"
            },
            {
              "title": "4.2 Built on demand, torn down in reverse",
              "href": "/4-runner/4-2-custom-fixtures/"
            }
          ]
        }
      ],
      "flow": [
        {
          "node": "browser",
          "step": "a-browser-holds-two-contexts",
          "log": []
        },
        {
          "node": "contextA",
          "step": "a-browser-holds-two-contexts",
          "log": [],
          "edge": "browserA"
        },
        {
          "node": "browser",
          "step": "a-browser-holds-two-contexts",
          "log": []
        },
        {
          "node": "contextB",
          "step": "a-browser-holds-two-contexts",
          "log": [],
          "edge": "browserB"
        },
        {
          "node": "contextA",
          "step": "each-page-contains-a-main-frame",
          "log": []
        },
        {
          "node": "pageA",
          "step": "each-page-contains-a-main-frame",
          "log": [],
          "edge": "contextA"
        },
        {
          "node": "mainA",
          "step": "each-page-contains-a-main-frame",
          "log": [],
          "edge": "pageA"
        },
        {
          "node": "childA",
          "step": "each-page-contains-a-main-frame",
          "log": [],
          "edge": "mainA"
        },
        {
          "node": "nestedA",
          "step": "each-page-contains-a-main-frame",
          "log": [],
          "edge": "childA"
        },
        {
          "node": "contextB",
          "step": "the-contexts-have-separate-cooki",
          "log": []
        }
      ]
    },
    {
      "id": "context",
      "label": "Close context",
      "display": {
        "counterLabel": true,
        "edges": "all",
        "edgeBadges": false,
        "nodeBadges": true,
        "log": "incremental"
      },
      "whole": {
        "title": "Close one explicit context",
        "text": "Context B and its page remain available."
      },
      "steps": [
        {
          "id": "close-context-a",
          "title": "Close Context A.",
          "text": "Close Context A. Context B and its page remain available.",
          "show": [
            "browser",
            "contextA",
            "pageA",
            "mainA",
            "childA",
            "nestedA",
            "contextB",
            "pageB",
            "mainB",
            "childB",
            "nestedB"
          ],
          "current": [
            "contextA"
          ],
          "edges": [],
          "defs": [
            "state"
          ],
          "log": [],
          "sources": [
            {
              "label": "class-browsercontext.md:596",
              "url": "https://github.com/microsoft/playwright/blob/v1.65.0/docs/src/api/class-browsercontext.md#L596"
            },
            {
              "label": "browsercontext-basic.spec.ts:24-33",
              "url": "https://github.com/microsoft/playwright/blob/v1.65.0/tests/library/browsercontext-basic.spec.ts#L24-L33"
            }
          ],
          "deeper": [
            {
              "title": "0.1 API calls leave from Node, page calls from the browser",
              "href": "/0-anatomy/0-1-anatomy-of-a-test/"
            },
            {
              "title": "1.1 A failed call comes back with its name and its call log",
              "href": "/1-messages/1-1-one-call-two-processes/"
            },
            {
              "title": "4.2 Built on demand, torn down in reverse",
              "href": "/4-runner/4-2-custom-fixtures/"
            }
          ]
        },
        {
          "id": "its-page-and-frame-tree-close-wi",
          "title": "Its page and frame tree close with it.",
          "text": "Its page and frame tree close with it.",
          "show": [],
          "current": [
            "pageA",
            "mainA",
            "childA",
            "nestedA"
          ],
          "edges": [
            "contextA",
            "pageA",
            "mainA",
            "childA"
          ],
          "defs": [
            "closedA"
          ],
          "log": [],
          "sources": [
            {
              "label": "class-browsercontext.md:596",
              "url": "https://github.com/microsoft/playwright/blob/v1.65.0/docs/src/api/class-browsercontext.md#L596"
            },
            {
              "label": "page.ts:207-217",
              "url": "https://github.com/microsoft/playwright/blob/v1.65.0/packages/playwright-core/src/server/page.ts#L207-L217"
            },
            {
              "label": "frames.ts:151-164",
              "url": "https://github.com/microsoft/playwright/blob/v1.65.0/packages/playwright-core/src/server/frames.ts#L151-L164"
            },
            {
              "label": "browsercontext-basic.spec.ts:24-33",
              "url": "https://github.com/microsoft/playwright/blob/v1.65.0/tests/library/browsercontext-basic.spec.ts#L24-L33"
            }
          ],
          "deeper": [
            {
              "title": "0.1 API calls leave from Node, page calls from the browser",
              "href": "/0-anatomy/0-1-anatomy-of-a-test/"
            },
            {
              "title": "1.1 A failed call comes back with its name and its call log",
              "href": "/1-messages/1-1-one-call-two-processes/"
            },
            {
              "title": "4.2 Built on demand, torn down in reverse",
              "href": "/4-runner/4-2-custom-fixtures/"
            }
          ]
        },
        {
          "id": "context-b-stays-available",
          "title": "Context B stays available.",
          "text": "Context B stays available.",
          "show": [],
          "current": [
            "contextB",
            "pageB"
          ],
          "edges": [
            "contextB"
          ],
          "defs": [
            "closedA"
          ],
          "log": [],
          "sources": [
            {
              "label": "browsercontext-basic.spec.ts:24-33",
              "url": "https://github.com/microsoft/playwright/blob/v1.65.0/tests/library/browsercontext-basic.spec.ts#L24-L33"
            }
          ],
          "deeper": [
            {
              "title": "0.1 API calls leave from Node, page calls from the browser",
              "href": "/0-anatomy/0-1-anatomy-of-a-test/"
            },
            {
              "title": "1.1 A failed call comes back with its name and its call log",
              "href": "/1-messages/1-1-one-call-two-processes/"
            },
            {
              "title": "4.2 Built on demand, torn down in reverse",
              "href": "/4-runner/4-2-custom-fixtures/"
            }
          ]
        }
      ],
      "flow": [
        {
          "node": "contextA",
          "step": "close-context-a",
          "log": []
        },
        {
          "node": "pageA",
          "step": "its-page-and-frame-tree-close-wi",
          "log": [],
          "edge": "contextA"
        },
        {
          "node": "mainA",
          "step": "its-page-and-frame-tree-close-wi",
          "log": [],
          "edge": "pageA"
        },
        {
          "node": "childA",
          "step": "its-page-and-frame-tree-close-wi",
          "log": [],
          "edge": "mainA"
        },
        {
          "node": "nestedA",
          "step": "its-page-and-frame-tree-close-wi",
          "log": [],
          "edge": "childA"
        },
        {
          "node": "contextB",
          "step": "context-b-stays-available",
          "log": []
        },
        {
          "node": "pageB",
          "step": "context-b-stays-available",
          "log": [],
          "edge": "contextB"
        }
      ]
    },
    {
      "id": "boundaries",
      "label": "Close boundaries",
      "display": {
        "counterLabel": true,
        "edges": "all",
        "edgeBadges": false,
        "nodeBadges": true,
        "log": "incremental"
      },
      "whole": {
        "title": "Browser closure and the shortcut",
        "text": "browser.newPage() creates a context owned by its page."
      },
      "steps": [
        {
          "id": "closing-the-browser-closes-every",
          "title": "Closing the browser closes every context.",
          "text": "Closing the browser closes every context.",
          "show": [
            "browser",
            "contextA",
            "pageA",
            "mainA",
            "childA",
            "nestedA",
            "contextB",
            "pageB",
            "mainB",
            "childB",
            "nestedB"
          ],
          "current": [
            "browser",
            "contextA",
            "contextB"
          ],
          "edges": [
            "browserA",
            "browserB"
          ],
          "defs": [
            "closedBoth"
          ],
          "log": [],
          "sources": [
            {
              "label": "browser.ts:174-178",
              "url": "https://github.com/microsoft/playwright/blob/v1.65.0/packages/playwright-core/src/server/browser.ts#L174-L178"
            },
            {
              "label": "browserContext.ts:256-260",
              "url": "https://github.com/microsoft/playwright/blob/v1.65.0/packages/playwright-core/src/server/browserContext.ts#L256-L260"
            }
          ],
          "deeper": [
            {
              "title": "0.1 API calls leave from Node, page calls from the browser",
              "href": "/0-anatomy/0-1-anatomy-of-a-test/"
            },
            {
              "title": "1.1 A failed call comes back with its name and its call log",
              "href": "/1-messages/1-1-one-call-two-processes/"
            },
            {
              "title": "4.2 Built on demand, torn down in reverse",
              "href": "/4-runner/4-2-custom-fixtures/"
            }
          ]
        },
        {
          "id": "browser-newpage-creates-a-page-a",
          "title": "browser.newPage() creates a page and its own context.",
          "text": "browser.newPage() creates a page and its own context. This is the separate shortcut example.",
          "show": [
            "shortcut",
            "owned"
          ],
          "current": [
            "shortcut",
            "owned"
          ],
          "edges": [
            "owns"
          ],
          "defs": [
            "shortcut"
          ],
          "log": [],
          "sources": [
            {
              "label": "browser.ts:145-152",
              "url": "https://github.com/microsoft/playwright/blob/v1.65.0/packages/playwright-core/src/client/browser.ts#L145-L152"
            },
            {
              "label": "page.ts:709-719",
              "url": "https://github.com/microsoft/playwright/blob/v1.65.0/packages/playwright-core/src/client/page.ts#L709-L719"
            }
          ],
          "deeper": [
            {
              "title": "0.1 API calls leave from Node, page calls from the browser",
              "href": "/0-anatomy/0-1-anatomy-of-a-test/"
            },
            {
              "title": "1.1 A failed call comes back with its name and its call log",
              "href": "/1-messages/1-1-one-call-two-processes/"
            },
            {
              "title": "4.2 Built on demand, torn down in reverse",
              "href": "/4-runner/4-2-custom-fixtures/"
            }
          ]
        },
        {
          "id": "closing-that-page-also-closes-it",
          "title": "Closing that page also closes its owned context.",
          "text": "Closing that page also closes its owned context.",
          "show": [],
          "current": [
            "owned"
          ],
          "edges": [],
          "defs": [
            "closedOwned",
            "ordinary"
          ],
          "code": "close",
          "log": [],
          "sources": [
            {
              "label": "page.ts:709-719",
              "url": "https://github.com/microsoft/playwright/blob/v1.65.0/packages/playwright-core/src/client/page.ts#L709-L719"
            }
          ],
          "deeper": [
            {
              "title": "0.1 API calls leave from Node, page calls from the browser",
              "href": "/0-anatomy/0-1-anatomy-of-a-test/"
            },
            {
              "title": "1.1 A failed call comes back with its name and its call log",
              "href": "/1-messages/1-1-one-call-two-processes/"
            },
            {
              "title": "4.2 Built on demand, torn down in reverse",
              "href": "/4-runner/4-2-custom-fixtures/"
            }
          ]
        }
      ],
      "flow": [
        {
          "node": "browser",
          "step": "closing-the-browser-closes-every",
          "log": []
        },
        {
          "node": "contextA",
          "step": "closing-the-browser-closes-every",
          "log": [],
          "edge": "browserA"
        },
        {
          "node": "browser",
          "step": "closing-the-browser-closes-every",
          "log": []
        },
        {
          "node": "contextB",
          "step": "closing-the-browser-closes-every",
          "log": [],
          "edge": "browserB"
        },
        {
          "node": "shortcut",
          "step": "browser-newpage-creates-a-page-a",
          "log": []
        },
        {
          "node": "owned",
          "step": "browser-newpage-creates-a-page-a",
          "log": [],
          "edge": "owns"
        },
        {
          "node": "shortcut",
          "step": "closing-that-page-also-closes-it",
          "log": []
        },
        {
          "node": "owned",
          "step": "closing-that-page-also-closes-it",
          "log": [],
          "edge": "owns"
        }
      ]
    },
    {
      "id": "closed",
      "label": "Closed page",
      "display": {
        "counterLabel": true,
        "edges": "all",
        "edgeBadges": false,
        "nodeBadges": true,
        "log": "incremental"
      },
      "whole": {
        "title": "Call a page after closing",
        "text": "The error does not identify which close ran first."
      },
      "steps": [
        {
          "id": "context-a-has-already-closed-its",
          "title": "Context A has already closed its page.",
          "text": "Context A has already closed its page.",
          "show": [
            "browser",
            "contextA",
            "pageA",
            "mainA",
            "childA",
            "nestedA",
            "contextB",
            "pageB",
            "mainB",
            "childB",
            "nestedB"
          ],
          "current": [
            "contextA",
            "pageA"
          ],
          "edges": [
            "contextA"
          ],
          "defs": [
            "closedA"
          ],
          "log": [],
          "sources": [
            {
              "label": "class-browsercontext.md:596",
              "url": "https://github.com/microsoft/playwright/blob/v1.65.0/docs/src/api/class-browsercontext.md#L596"
            },
            {
              "label": "browsercontext-basic.spec.ts:24-33",
              "url": "https://github.com/microsoft/playwright/blob/v1.65.0/tests/library/browsercontext-basic.spec.ts#L24-L33"
            }
          ],
          "deeper": [
            {
              "title": "0.1 API calls leave from Node, page calls from the browser",
              "href": "/0-anatomy/0-1-anatomy-of-a-test/"
            },
            {
              "title": "1.1 A failed call comes back with its name and its call log",
              "href": "/1-messages/1-1-one-call-two-processes/"
            },
            {
              "title": "4.2 Built on demand, torn down in reverse",
              "href": "/4-runner/4-2-custom-fixtures/"
            }
          ]
        },
        {
          "id": "the-test-calls-page-a-after-clos",
          "title": "The test calls Page A after closing.",
          "text": "The test calls Page A after closing.",
          "show": [
            "call"
          ],
          "current": [
            "call"
          ],
          "edges": [],
          "defs": [
            "closedA"
          ],
          "log": [],
          "sources": [
            {
              "label": "dispatcher.ts:315-318",
              "url": "https://github.com/microsoft/playwright/blob/v1.65.0/packages/playwright-core/src/server/dispatchers/dispatcher.ts#L315-L318"
            }
          ],
          "deeper": [
            {
              "title": "0.1 API calls leave from Node, page calls from the browser",
              "href": "/0-anatomy/0-1-anatomy-of-a-test/"
            },
            {
              "title": "1.1 A failed call comes back with its name and its call log",
              "href": "/1-messages/1-1-one-call-two-processes/"
            },
            {
              "title": "4.2 Built on demand, torn down in reverse",
              "href": "/4-runner/4-2-custom-fixtures/"
            }
          ]
        },
        {
          "id": "no-server-object-answers-the-cal",
          "title": "No server object answers. The call fails.",
          "text": "No server object answers. The call fails. The error does not identify which close ran first.",
          "show": [
            "error"
          ],
          "current": [
            "error"
          ],
          "edges": [
            "closed"
          ],
          "defs": [
            "target"
          ],
          "log": [
            "Target page, context or browser has been closed"
          ],
          "sources": [
            {
              "label": "dispatcher.ts:315-318",
              "url": "https://github.com/microsoft/playwright/blob/v1.65.0/packages/playwright-core/src/server/dispatchers/dispatcher.ts#L315-L318"
            },
            {
              "label": "errors.ts:36-39",
              "url": "https://github.com/microsoft/playwright/blob/v1.65.0/packages/playwright-core/src/server/errors.ts#L36-L39"
            }
          ],
          "deeper": [
            {
              "title": "0.1 API calls leave from Node, page calls from the browser",
              "href": "/0-anatomy/0-1-anatomy-of-a-test/"
            },
            {
              "title": "1.1 A failed call comes back with its name and its call log",
              "href": "/1-messages/1-1-one-call-two-processes/"
            },
            {
              "title": "4.2 Built on demand, torn down in reverse",
              "href": "/4-runner/4-2-custom-fixtures/"
            }
          ]
        }
      ],
      "flow": [
        {
          "node": "contextA",
          "step": "context-a-has-already-closed-its",
          "log": []
        },
        {
          "node": "pageA",
          "step": "context-a-has-already-closed-its",
          "log": [],
          "edge": "contextA"
        },
        {
          "node": "call",
          "step": "the-test-calls-page-a-after-clos",
          "log": []
        },
        {
          "node": "error",
          "step": "no-server-object-answers-the-cal",
          "log": [
            "Target page, context or browser has been closed"
          ],
          "edge": "closed",
          "fail": true
        }
      ]
    }
  ],
  "definitions": {
    "browser": {
      "term": "Browser",
      "text": "A browser holds contexts. These are logical object relationships, not a process per object."
    },
    "context": {
      "term": "Context",
      "text": "A context holds pages and keeps its own cookies and local storage."
    },
    "page": {
      "term": "Page",
      "text": "Each page has one main frame; iframes add child frames."
    },
    "frame": {
      "term": "Frame tree",
      "text": "A main frame contains child frames, which can contain nested frames."
    },
    "isolation": {
      "term": "Separate state",
      "text": "Both pages open the same example site. Their contexts do not share cookies or local storage."
    },
    "state": {
      "term": "Example state",
      "text": "Context A · ID A; cookies + storage · A; available ✓. Context B · ID B; cookies + storage · B; available ✓."
    },
    "closedA": {
      "term": "Example state",
      "text": "Context A: closed; its Page A and frame tree: closed. Context B and Page B: available ✓."
    },
    "closedBoth": {
      "term": "Example state",
      "text": "Context A and Context B: closed; both pages and their frame trees: closed."
    },
    "shortcut": {
      "term": "Page-owned context",
      "text": "browser.newPage() creates a page and its own context. Closing that page also closes its owned context."
    },
    "ordinary": {
      "term": "Ordinary page.close()",
      "text": "Without an owned context, page.close() closes the page channel by default."
    },
    "closedOwned": {
      "term": "Example state",
      "text": "The shortcut page and its page-owned context are closed."
    },
    "target": {
      "term": "Closed target",
      "text": "No server object answers the call. The error does not identify which close ran first."
    }
  },
  "code": {
    "id": {
      "title": "Inside Playwright · crBrowser.ts",
      "source": {
        "label": "crBrowser.ts:128-128",
        "url": "https://github.com/microsoft/playwright/blob/v1.65.0/packages/playwright-core/src/server/chromium/crBrowser.ts#L128"
      },
      "lines": [
        "const { browserContextId } =",
        "  await this._session.send(",
        "    'Target.createBrowserContext', {",
        "      disposeOnDetach: true,",
        "      proxyServer: proxy",
        "        ? proxy.server : undefined,",
        "      proxyBypassList,",
        "    });"
      ]
    },
    "users": {
      "title": "In your test · two users",
      "lines": [
        "// ✗ Both users share one cookie jar",
        "const alice = await context.newPage();",
        "const bob = await context.newPage();",
        "// ✓ Give each user a context",
        "const a = await browser.newContext();",
        "const b = await browser.newContext();",
        "const alicePage = await a.newPage();",
        "const bobPage = await b.newPage();"
      ]
    },
    "close": {
      "title": "Inside Playwright · page.ts",
      "source": {
        "label": "page.ts:714-714",
        "url": "https://github.com/microsoft/playwright/blob/v1.65.0/packages/playwright-core/src/client/page.ts#L714"
      },
      "lines": [
        "if (this._ownedContext)",
        "  await this._ownedContext.close();",
        "else if (options.runBeforeUnload)",
        "  await this._channel.runBeforeUnload(",
        "    {}, kNoTimeout);",
        "else",
        "  await this._channel.close(",
        "    { reason: options.reason }, kNoTimeout);"
      ]
    }
  },
  "conceptScenario": "how",
  "concepts": [
    {
      "label": "Logical browser and pages",
      "layer": "server",
      "items": [
        {
          "definition": "browser",
          "short": "Creates a context and applies its initial storage state.",
          "nodes": [
            "browser"
          ],
          "step": {
            "step": "a-browser-holds-contexts"
          },
          "source": {
            "label": "browser.ts:116-123",
            "url": "https://github.com/microsoft/playwright/blob/v1.65.0/packages/playwright-core/src/server/browser.ts#L116-L123"
          }
        },
        {
          "definition": "page",
          "short": "Adopts its main frame.",
          "nodes": [
            "pageA"
          ],
          "step": {
            "step": "each-page-has-a-main-frame"
          },
          "source": {
            "label": "pageDispatcher.ts:88-100",
            "url": "https://github.com/microsoft/playwright/blob/v1.65.0/packages/playwright-core/src/server/dispatchers/pageDispatcher.ts#L88-L100"
          }
        },
        {
          "definition": "ordinary",
          "short": "Closes the page channel by default without an owned context.",
          "nodes": [
            "pageA"
          ],
          "step": {
            "step": "the-shortcut-owns-a-context"
          },
          "source": {
            "label": "page.ts:709-719",
            "url": "https://github.com/microsoft/playwright/blob/v1.65.0/packages/playwright-core/src/client/page.ts#L709-L719"
          }
        }
      ]
    },
    {
      "label": "Contexts",
      "layer": "browser",
      "items": [
        {
          "definition": "shortcut",
          "short": "Creates a page and its owned context.",
          "nodes": [
            "owned"
          ],
          "step": {
            "step": "the-shortcut-owns-a-context"
          },
          "source": {
            "label": "browser.ts:145-152",
            "url": "https://github.com/microsoft/playwright/blob/v1.65.0/packages/playwright-core/src/client/browser.ts#L145-L152"
          }
        },
        {
          "definition": "context",
          "short": "Chromium creates each context with its own ID.",
          "nodes": [
            "contextA"
          ],
          "step": {
            "step": "a-context-holds-pages"
          },
          "source": {
            "label": "crBrowser.ts:128-136",
            "url": "https://github.com/microsoft/playwright/blob/v1.65.0/packages/playwright-core/src/server/chromium/crBrowser.ts#L128-L136"
          }
        },
        {
          "definition": "isolation",
          "short": "Same-origin contexts keep distinct cookies and local storage.",
          "nodes": [
            "contextA",
            "contextB"
          ],
          "step": {
            "step": "contexts-keep-state-apart"
          },
          "source": {
            "label": "browsercontext-basic.spec.ts:118-153",
            "url": "https://github.com/microsoft/playwright/blob/v1.65.0/tests/library/browsercontext-basic.spec.ts#L118-L153"
          }
        }
      ]
    },
    {
      "label": "Frame trees",
      "layer": "page",
      "items": [
        {
          "definition": "frame",
          "short": "Collects the main frame and child frames recursively.",
          "nodes": [
            "mainA",
            "childA",
            "nestedA"
          ],
          "step": {
            "step": "iframes-add-child-frames"
          },
          "source": {
            "label": "frames.ts:151-164",
            "url": "https://github.com/microsoft/playwright/blob/v1.65.0/packages/playwright-core/src/server/frames.ts#L151-L164"
          }
        }
      ]
    },
    {
      "label": "Failed call",
      "layer": "fail",
      "items": [
        {
          "definition": "target",
          "short": "A missing server object answers with a target-closed error.",
          "nodes": [
            "error"
          ],
          "step": {
            "step": "a-call-after-closing-fails"
          },
          "source": {
            "label": "dispatcher.ts:315-318",
            "url": "https://github.com/microsoft/playwright/blob/v1.65.0/packages/playwright-core/src/server/dispatchers/dispatcher.ts#L315-L318"
          }
        }
      ]
    }
  ],
  "callouts": {
    "1": [
      "browser",
      "contextA",
      "pageA",
      "mainA",
      "childA",
      "nestedA"
    ],
    "2": [
      "contextA",
      "contextB"
    ],
    "3": [
      "browser",
      "contextA",
      "contextB",
      "owned",
      "shortcut"
    ],
    "4": [
      "call",
      "error"
    ]
  },
  "deeper": [
    {
      "title": "0.1 API calls leave from Node, page calls from the browser",
      "href": "/0-anatomy/0-1-anatomy-of-a-test/",
      "why": "Where the logical objects run."
    },
    {
      "title": "1.1 A failed call comes back with its name and its call log",
      "href": "/1-messages/1-1-one-call-two-processes/",
      "why": "How a failed call returns."
    },
    {
      "title": "1.3 Your script and Playwright's checks share the page, not its variables",
      "href": "/1-messages/1-3-two-worlds/",
      "why": "The worlds inside a frame."
    },
    {
      "title": "4.2 Built on demand, torn down in reverse",
      "href": "/4-runner/4-2-custom-fixtures/",
      "why": "Fixture lifetimes and teardown."
    }
  ]
}
