Auto merge of #22802 - gterzian:only_run_tasks_for_fully_active_docs, r=nox

In BC event-loop, only run tasks related to fully-active documents

<!-- Please describe your changes on the following line: -->

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [ ] `./mach build -d` does not report any errors
- [ ] `./mach test-tidy` does not report any errors
- [ ] These changes fix #22792 (GitHub issue number if applicable)

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because ___

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22802)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2019-03-11 12:32:03 -04:00 committed by GitHub
commit f2ea73f360
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 219 additions and 14 deletions

View file

@ -0,0 +1,29 @@
async_test(t => {
const frame = document.body.appendChild(document.createElement("iframe"));
t.add_cleanup(() => frame.remove());
frame.onload = t.step_func(() => {
// Right now the doc of the iframe inside "frame" is still "fully-active".
// Navigate parent away, making the child iframe's doc "active", not "fully-active".
frame.contentWindow.location = "/common/blank.html";
frame.onload = t.step_func(() => {
// The child iframe's doc is "active", not "fully-active", and should not receive the storage notification.
sessionStorage.setItem('myCat', 'Tom');
t.step_timeout(() => {
// The child iframe's hasn't received the storage notification.
assert_equals(sessionStorage.getItem("Received storage event"), null);
frame.contentWindow.history.go(-1);
t.step_timeout(() => {
// Now The child iframe's doc is "fully-active" again,
// the previously not run storage task should now have been run.
assert_equals(sessionStorage.getItem("Received storage event"), "true");
t.done();
}, 1000);
}, 1000);
});
});
frame.src = "resources/page-with-frame.html";
}, "Tasks for documents that are not fully active are stored, and run when the documents becomes fully-active");

View file

@ -0,0 +1,7 @@
<!doctype html>
<title>Childframe</title>
<script>
window.addEventListener('storage', () => {
sessionStorage.setItem("Received storage event", true);
});
</script>

View file

@ -0,0 +1 @@
<iframe src="iframe.html"></iframe>