| <!DOCTYPE html> <!-- webkit-test-runner [ SpatialPortalEnabled=true ModelElementEnabled=true ModelProcessEnabled=true allowTestOnlyIPC=true ] --> | |
| <html> | |
| <script src="../resources/testharness.js"></script> | |
| <script src="../resources/testharnessreport.js"></script> | |
| <script src="../resources/ui-helper.js"></script> | |
| <style> | |
| .spacer { height: 500vh; } | |
| #portal { spatial: portal; width: 300px; height: 150px; } | |
| </style> | |
| <body> | |
| <div class="spacer"></div> | |
| <div id="portal"></div> | |
| <script> | |
| 'use strict'; | |
| promise_test(async t => { | |
| const portal = document.getElementById("portal"); | |
| const model = document.createElement("model"); | |
| t.add_cleanup(() => model.remove()); | |
| portal.appendChild(model); | |
| const source = document.createElement("source"); | |
| source.src = "../model-element/resources/cube.usdz"; | |
| model.appendChild(source); | |
| await UIHelper.ensureStablePresentationUpdate(); | |
| assert_not_equals(internals.modelElementState(model), "Loaded", "portal does not load its model while off-screen"); | |
| portal.scrollIntoView(); | |
| await model.ready; | |
| assert_equals(internals.modelElementState(model), "Loaded", "portal loads the model after scrolling into view"); | |
| }, "A <model> in a spatial portal loads only once the portal is scrolled into view"); | |
| </script> | |
| </body> | |
| </html> |