(global)
| 412 | * @return {!Promise} |
| 413 | */ |
| 414 | export function adoptShadowMode(global) { |
| 415 | return adoptShared(global, (global, extensions) => { |
| 416 | // shadow mode already adopted |
| 417 | if (global.AMP.attachShadowDoc) { |
| 418 | return Promise.resolve(); |
| 419 | } |
| 420 | |
| 421 | // Dependencies to the MultiDocManager |
| 422 | adoptMultiDocDeps(global); |
| 423 | |
| 424 | const manager = new MultidocManager( |
| 425 | global, |
| 426 | Services.ampdocServiceFor(global), |
| 427 | extensions, |
| 428 | Services.timerFor(global) |
| 429 | ); |
| 430 | |
| 431 | /** |
| 432 | * Registers a shadow root document via a fully fetched document. |
| 433 | * @param {!Element} hostElement |
| 434 | * @param {!Document} doc |
| 435 | * @param {string} url |
| 436 | * @param {!{[key: string]: string}=} opt_initParams |
| 437 | * @return {!Object} |
| 438 | */ |
| 439 | global.AMP.attachShadowDoc = manager.attachShadowDoc.bind(manager); |
| 440 | |
| 441 | /** |
| 442 | * Registers a shadow root document via a stream. |
| 443 | * @param {!Element} hostElement |
| 444 | * @param {string} url |
| 445 | * @param {!{[key: string]: string}=} opt_initParams |
| 446 | * @return {!Object} |
| 447 | */ |
| 448 | global.AMP.attachShadowDocAsStream = |
| 449 | manager.attachShadowDocAsStream.bind(manager); |
| 450 | |
| 451 | return waitForBodyOpenPromise(global.document); |
| 452 | }); |
| 453 | } |
| 454 | |
| 455 | /** |
| 456 | * For a given extension, checks that its version is the same |
no test coverage detected