* Adopt shared runtimes variables between both multi-doc and single-doc pages * @param {!Window} global Global scope to adopt.
(global)
| 371 | * @param {!Window} global Global scope to adopt. |
| 372 | */ |
| 373 | function adoptServicesAndResources(global) { |
| 374 | const {documentElement} = global.document; |
| 375 | |
| 376 | const ampdocService = Services.ampdocServiceFor(global); |
| 377 | const ampdoc = ampdocService.getSingleDoc(); |
| 378 | global.AMP.ampdoc = ampdoc; |
| 379 | |
| 380 | const viewer = Services.viewerForDoc(documentElement); |
| 381 | global.AMP.viewer = viewer; |
| 382 | |
| 383 | if (getMode().development) { |
| 384 | global.AMP.toggleRuntime = viewer.toggleRuntime.bind(viewer); |
| 385 | global.AMP.resources = Services.resourcesForDoc(documentElement); |
| 386 | } |
| 387 | |
| 388 | const viewport = Services.viewportForDoc(documentElement); |
| 389 | global.AMP.viewport = {}; |
| 390 | global.AMP.viewport.getScrollLeft = viewport.getScrollLeft.bind(viewport); |
| 391 | global.AMP.viewport.getScrollWidth = viewport.getScrollWidth.bind(viewport); |
| 392 | global.AMP.viewport.getWidth = viewport.getWidth.bind(viewport); |
| 393 | } |
| 394 | |
| 395 | /** |
| 396 | * Adopt MultiDocManager dependencies |
no test coverage detected