Skip to content

Implement beforeunload event and infrastructure - #20329

Merged
bors-servo merged 4 commits into
servo:masterfrom
gterzian:before_unload
May 7, 2018
Merged

bors-servo merged 4 commits into
servo:masterfrom
gterzian:before_unload

Conversation

@gterzian

@gterzian gterzian commented Mar 18, 2018 •

Copy link
Copy Markdown
Member

@highfive

Copy link
Copy Markdown

Heads up! This PR modifies the following files:

  • @asajeffrey: components/script/dom/document.rs, components/script/dom/window.rs, components/script/dom/eventtarget.rs
  • @fitzgen: components/script/dom/document.rs, components/script/dom/window.rs, components/script/dom/eventtarget.rs
  • @KiChjang: components/script/dom/document.rs, components/script/dom/window.rs, components/script/dom/eventtarget.rs

@servo-wpt-sync

Copy link
Copy Markdown
Collaborator

Opened new PR for upstreamable changes.

Completed upstream sync of web-platform-test changes at jdm/web-platform-tests#36.

@servo-wpt-sync

Copy link
Copy Markdown
Collaborator

Error syncing changes upstream. Logs saved in error-snapshot-1521386860024.

@servo-wpt-sync

Copy link
Copy Markdown
Collaborator

Error syncing changes upstream. Logs saved in error-snapshot-1521387016450.

@servo-wpt-sync

Copy link
Copy Markdown
Collaborator

No upstreamable changes; closed existing PR.

Completed upstream sync of web-platform-test changes at jdm/web-platform-tests#36.

@servo-wpt-sync

Copy link
Copy Markdown
Collaborator

Opened new PR for upstreamable changes.

Completed upstream sync of web-platform-test changes at jdm/web-platform-tests#46.

@servo-wpt-sync

Copy link
Copy Markdown
Collaborator

No upstreamable changes; closed existing PR.

Completed upstream sync of web-platform-test changes at jdm/web-platform-tests#46.

@gterzian
gterzian force-pushed the before_unload branch 4 times, most recently from 2afab18 to 31a8d18 Compare March 31, 2018 15:08
@gterzian
gterzian force-pushed the before_unload branch 3 times, most recently from 9370ab6 to b8c983b Compare April 1, 2018 07:29
@servo-wpt-sync

Copy link
Copy Markdown
Collaborator

Opened new PR for upstreamable changes.

Completed upstream sync of web-platform-test changes at jdm/web-platform-tests#47.

@servo-wpt-sync

Copy link
Copy Markdown
Collaborator

Transplanted upstreamable changes to existing PR.

Completed upstream sync of web-platform-test changes at jdm/web-platform-tests#47.

@servo-wpt-sync

Copy link
Copy Markdown
Collaborator

No upstreamable changes; closed existing PR.

Completed upstream sync of web-platform-test changes at jdm/web-platform-tests#57.

// TODO: Step 6, decrease the event loop's termination nesting level by 1.
// Step 7
self.salvageable.set(has_listeners);
self.salvageable.set(!has_listeners);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cbrewster This was the problem, LOL

@gterzian

gterzian commented May 4, 2018

Copy link
Copy Markdown
Member Author

Ok, should be good to go...

@cbrewster cbrewster left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks

@cbrewster

Copy link
Copy Markdown
Contributor

@bors-servo r+

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 99eaab4 has been approved by cbrewster

@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 99eaab4 with merge ae80a01...

@bors-servo

Copy link
Copy Markdown
Contributor

💔 Test failed - mac-dev-unit

@cbrewster

cbrewster commented May 4, 2018 •

Copy link
Copy Markdown
Contributor

More things passing (maybe due to the PutForwards?)
Also need to check on the crash.
Failures:

Details
{"status": "PASS", "group": "default", "message": null, "stack": null, "subtest": "Document interface: iframe.contentDocument must have own property \"location\"", "test": "/html/dom/interfaces.https.html", "line": 37757, "action": "test_result", "expected": "FAIL"}
{"status": "PASS", "group": "default", "message": null, "stack": null, "subtest": "Document interface: new Document() must have own property \"location\"", "test": "/html/dom/interfaces.https.html", "line": 37878, "action": "test_result", "expected": "FAIL"}
{"status": "PASS", "group": "default", "message": null, "stack": null, "subtest": "Document interface: document.implementation.createDocument(null, \"\", null) must have own property \"location\"", "test": "/html/dom/interfaces.https.html", "line": 37999, "action": "test_result", "expected": "FAIL"}
{"status": "PASS", "group": "default", "message": null, "stack": null, "subtest": "Window interface: window must have own property \"location\"", "test": "/html/dom/interfaces.https.html", "line": 43329, "action": "test_result", "expected": "FAIL"}
{"status": "CRASH", "group": "default", "message": null, "stack": null, "subtest": null, "test": "/html/browsers/browsing-the-web/unloading-documents/navigation-within-beforeunload.html", "line": 63084, "action": "test_result", "expected": "OK"}

@jdm

jdm commented May 4, 2018 •

Copy link
Copy Markdown
Member
  ▶ CRASH [expected OK] /html/browsers/browsing-the-web/unloading-documents/navigation-within-beforeunload.html
  │ 
  │ VMware, Inc.
  │ softpipe
  │ 3.3 (Core Profile) Mesa 17.3.0-devel
  │ ERROR 2018-05-04T16:55:30Z: webrender::display_list_flattener: Unknown pipeline used for iframe IframeDisplayItem { clip_id: Clip(2, PipelineId(0, 1)), pipeline_id: PipelineId(1, 2) }
  │ ERROR 2018-05-04T16:55:30Z: webrender::display_list_flattener: Unknown pipeline used for iframe IframeDisplayItem { clip_id: Clip(2, PipelineId(0, 1)), pipeline_id: PipelineId(1, 2) }
  │ ERROR 2018-05-04T16:55:30Z: webrender::display_list_flattener: Unknown pipeline used for iframe IframeDisplayItem { clip_id: Clip(2, PipelineId(0, 1)), pipeline_id: PipelineId(1, 2) }
  │ ERROR 2018-05-04T16:55:30Z: webrender::display_list_flattener: Unknown pipeline used for iframe IframeDisplayItem { clip_id: Clip(2, PipelineId(0, 1)), pipeline_id: PipelineId(1, 4) }
  │ ERROR 2018-05-04T16:55:30Z: script::dom::bindings::error: Error at http://web-platform.test:8000/html/browsers/browsing-the-web/unloading-documents/navigation-within-beforeunload-1.html?0.4542089685414288:7:3 too much recursion
  │ failed to open /dev/urandom: Os { code: 24, kind: Other, message: "Too many open files" } (thread LayoutThread PipelineId { namespace_id: PipelineNamespaceId(1), index: PipelineIndex(66) }, at libcore/result.rs:945)
  │ 2018-05-04 12:55:31.746 servo[66142:3566091681] Metadata.framework [Error]: couldn't get the client port
  │ stack backtrace:
  │    0:        0x1033c370e - backtrace::backtrace::trace::h7964d766053cc9d7
  │    1:        0x1033c2efc - backtrace::capture::Backtrace::new::h4b3e83f668a53406
  │    2:        0x10085c25e - servo::main::_$u7b$$u7b$closure$u7d$$u7d$::h8065021b052ffffd
  │    3:        0x1033ed564 - std::panicking::rust_panic_with_hook::hcebe05e8466ff134
  │    4:        0x1033ed050 - std::panicking::begin_panic_fmt::hf6867449b867ca07
  │    5:        0x1033ed012 - rust_begin_unwind
  │    6:        0x1033ff315 - core::panicking::panic_fmt::h794f4a50949acedc
  │    7:        0x1033e075d - core::result::unwrap_failed::h3e61bd84938f7a47
  │    8:        0x1033e174a - std::sys::unix::rand::hashmap_random_keys::h4ce375ed6694a11c
  │    9:        0x100c77182 - _$LT$std..collections..hash..map..HashMap$LT$K$C$$u20$V$C$$u20$S$GT$$u20$as$u20$core..default..Default$GT$::default::h9e0ca1059606c377
  │   10:        0x100c3749b - layout_thread::LayoutThread::new::hf1e7a8271e7dbb08
  │   11:        0x100b57d50 - std::sys_common::backtrace::__rust_begin_short_backtrace::h5089b87c9e789e86 (.llvm.4107249418266811869)
  │   12:        0x100bffc6d - std::panicking::try::do_call::ha0c91113a5e277a6 (.llvm.14984580951739245240)
  │   13:        0x1033f8d4e - __rust_maybe_catch_panic
  │   14:        0x100b690a6 - _$LT$F$u20$as$u20$alloc..boxed..FnBox$LT$A$GT$$GT$::call_box::h70501c75e780521c
  │   15:        0x1033e8ac7 - std::sys_common::thread::start_thread::h3a2a1586806f3926
  │   16:        0x1033d19f8 - std::sys::unix::thread::Thread::new::thread_start::h657bd8405a5d884c
  │   17:     0x7fff95aed059 - _pthread_body
  │   18:     0x7fff95aecfd6 - _pthread_start
  │ ERROR 2018-05-04T16:55:32Z: servo: failed to open /dev/urandom: Os { code: 24, kind: Other, message: "Too many open files" }
  └ Pipeline failed in hard-fail mode.  Crashing!

@jdm

jdm commented May 4, 2018

Copy link
Copy Markdown
Member

The crash from mac-dev-unit is not caused by these changes; it's clearly something wrong lower down in the Rust standard library:

  * frame #0: 0x000000010063a8f2 text_util-9a954535af80505d`std::panicking::panicking::hbf60d20c3ea01bc0 [inlined] core::ptr::swap_nonoverlapping_bytes::h5ceec518bedbc8b5 + 28 at ptr.rs:237 [opt]
    frame #1: 0x000000010063a8d6 text_util-9a954535af80505d`std::panicking::panicking::hbf60d20c3ea01bc0 [inlined] core::ptr::swap_nonoverlapping::h135f714f781a3d4a at ptr.rs:187 [opt]
    frame #2: 0x000000010063a8d6 text_util-9a954535af80505d`std::panicking::panicking::hbf60d20c3ea01bc0 [inlined] core::mem::swap::ha8a5fb0906ce1619 at mem.rs:634 [opt]
    frame #3: 0x000000010063a8d6 text_util-9a954535af80505d`std::panicking::panicking::hbf60d20c3ea01bc0 [inlined] core::mem::replace::hc5999657bde25f00 at mem.rs:691 [opt]
    frame #4: 0x000000010063a8d6 text_util-9a954535af80505d`std::panicking::panicking::hbf60d20c3ea01bc0 [inlined] _$LT$std..thread..local..LocalKey$LT$T$GT$$GT$::init::h03c530c70809d764 at local.rs:270 [opt]
    frame #5: 0x000000010063a8d6 text_util-9a954535af80505d`std::panicking::panicking::hbf60d20c3ea01bc0 [inlined] _$LT$std..thread..local..LocalKey$LT$T$GT$$GT$::try_with::h1ddab9e8e4e02c71 + 34 at local.rs:296 [opt]
    frame #6: 0x000000010063a8b4 text_util-9a954535af80505d`std::panicking::panicking::hbf60d20c3ea01bc0 [inlined] _$LT$std..thread..local..LocalKey$LT$T$GT$$GT$::with::h7ad9abd4ee126f73 at local.rs:248 [opt]
    frame #7: 0x000000010063a8b4 text_util-9a954535af80505d`std::panicking::panicking::hbf60d20c3ea01bc0 [inlined] std::panicking::update_panic_count::h8ff9c302601a529d at panicking.rs:240 [opt]
    frame #8: 0x000000010063a8b4 text_util-9a954535af80505d`std::panicking::panicking::hbf60d20c3ea01bc0 + 4 at panicking.rs:317 [opt]
    frame #9: 0x0000000100019363 text_util-9a954535af80505d`std::sys_common::backtrace::__rust_begin_short_backtrace::h5ce7af51dff78437 [inlined] std::thread::panicking::ha8ec11437d5dda69 + 563 at mod.rs:650 [opt]
    frame #10: 0x000000010001935e text_util-9a954535af80505d`std::sys_common::backtrace::__rust_begin_short_backtrace::h5ce7af51dff78437 [inlined] std::sys_common::poison::Flag::borrow::h4e2e930fbcd29fe9 at poison.rs:36 [opt]
    frame #11: 0x000000010001935e text_util-9a954535af80505d`std::sys_common::backtrace::__rust_begin_short_backtrace::h5ce7af51dff78437 [inlined] _$LT$std..sync..mutex..MutexGuard$LT$$u27$mutex$C$$u20$T$GT$$GT$::new::hf958532833c3eeee at mutex.rs:426 [opt]
    frame #12: 0x000000010001935e text_util-9a954535af80505d`std::sys_common::backtrace::__rust_begin_short_backtrace::h5ce7af51dff78437 [inlined] _$LT$std..sync..mutex..Mutex$LT$T$GT$$GT$::lock::h08aa85ea884e0a79 + 9 at mutex.rs:231 [opt]
    frame #13: 0x0000000100019355 text_util-9a954535af80505d`std::sys_common::backtrace::__rust_begin_short_backtrace::h5ce7af51dff78437 [inlined] test::run_test::run_test_inner::_$u7b$$u7b$closure$u7d$$u7d$::h293891f148241b3f + 508 at lib.rs:1414 [opt]
    frame #14: 0x0000000100019159 text_util-9a954535af80505d`std::sys_common::backtrace::__rust_begin_short_backtrace::h5ce7af51dff78437 + 41 at backtrace.rs:136 [opt]
    frame #15: 0x0000000100030388 text_util-9a954535af80505d`std::panicking::try::do_call::h317793a359ef8eae [inlined] std::thread::Builder::spawn::_$u7b$$u7b$closure$u7d$$u7d$::_$u7b$$u7b$closure$u7d$$u7d$::hce2a129863ba037b + 40 at mod.rs:409 [opt]
    frame #16: 0x0000000100030372 text_util-9a954535af80505d`std::panicking::try::do_call::h317793a359ef8eae [inlined] _$LT$std..panic..AssertUnwindSafe$LT$F$GT$$u20$as$u20$core..ops..function..FnOnce$LT$$LP$$RP$$GT$$GT$::call_once::ha38aec20aaf8023b at panic.rs:305 [opt]
    frame #17: 0x0000000100030372 text_util-9a954535af80505d`std::panicking::try::do_call::h317793a359ef8eae + 18 at panicking.rs:310 [opt]
    frame #18: 0x000000010064657f text_util-9a954535af80505d`__rust_maybe_catch_panic + 31 at lib.rs:105 [opt]
    frame #19: 0x000000010001ac55 text_util-9a954535af80505d`_$LT$F$u20$as$u20$alloc..boxed..FnBox$LT$A$GT$$GT$::call_box::hbda32c8bc14400fa [inlined] std::panicking::try::hd50d66bdaa9b80f6 + 57 at panicking.rs:289 [opt]
    frame #20: 0x000000010001ac1c text_util-9a954535af80505d`_$LT$F$u20$as$u20$alloc..boxed..FnBox$LT$A$GT$$GT$::call_box::hbda32c8bc14400fa [inlined] std::panic::catch_unwind::h23f85cf47b3beb69 + 7 at panic.rs:374 [opt]
    frame #21: 0x000000010001ac15 text_util-9a954535af80505d`_$LT$F$u20$as$u20$alloc..boxed..FnBox$LT$A$GT$$GT$::call_box::hbda32c8bc14400fa [inlined] std::thread::Builder::spawn::_$u7b$$u7b$closure$u7d$$u7d$::hb9992794009509d0 + 55 at mod.rs:408 [opt]
    frame #22: 0x000000010001abde text_util-9a954535af80505d`_$LT$F$u20$as$u20$alloc..boxed..FnBox$LT$A$GT$$GT$::call_box::hbda32c8bc14400fa + 46 at boxed.rs:638 [opt]
    frame #23: 0x0000000100637758 text_util-9a954535af80505d`std::sys_common::thread::start_thread::h3a2a1586806f3926 [inlined] _$LT$alloc..boxed..Box$LT$alloc..boxed..FnBox$LT$A$C$$u20$Output$u3d$R$GT$$u20$$u2b$$u20$$u27$a$GT$$u20$as$u20$core..ops..function..FnOnce$LT$A$GT$$GT$::call_once::he272aed47e96b55c + 136 at boxed.rs:648 [opt]
    frame #24: 0x0000000100637755 text_util-9a954535af80505d`std::sys_common::thread::start_thread::h3a2a1586806f3926 + 133 at thread.rs:24 [opt]
    frame #25: 0x0000000100629689 text_util-9a954535af80505d`std::sys::unix::thread::Thread::new::thread_start::h657bd8405a5d884c + 9 at thread.rs:90 [opt]
    frame #26: 0x00007fff8afbb05a libsystem_pthread.dylib`_pthread_body + 131
    frame #27: 0x00007fff8afbafd7 libsystem_pthread.dylib`_pthread_start + 176
    frame #28: 0x00007fff8afb83ed libsystem_pthread.dylib`thread_start + 13

MainThreadScriptMsg::Navigate(pipeline_id,
LoadData::new(url, Some(pipeline_id), referrer_policy, Some(doc.url())), replace)).unwrap();

// Step 4

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved Step 4 #navigating-across-documents from script_thread(previously this was done in response to receiving the MainThreadScriptMsg::Navigate sent a bit below) to here, which fits the spec steps better actually.

@gterzian

gterzian commented May 5, 2018 •

Copy link
Copy Markdown
Member Author

I've done #20329 (comment), which prevents the crash inside /html/browsers/browsing-the-web/unloading-documents/navigation-within-beforeunload.html, and left the test as expected FAIL.

Having read the spec a bit more closely, and the test, I think this test probably doesn't match the spec anymore(it was added back in web-platform-tests/wpt#304).

That is because the test seems to rely on an infinite loop where the navigation inside the beforeunload callback triggers another beforeunload event which triggers another callback and so on. It seems that Step 4 #navigating-across-documents precludes such an loop.

https://github.com/servo/servo/blob/8e978dab17e18ff62a9eda3089ba2b072cd2429b/tests/wpt/web-platform-tests/html/browsers/browsing-the-web/unloading-documents/navigation-within-beforeunload-1.html

@cbrewster

Copy link
Copy Markdown
Contributor

@gterzian that analysis looks correct. Since the navigation would be cancelled before another beforeunload event is fired, that test should fail according to the spec. The test should be fixed, but that can be done as a followup since I would like this to land.

@bors-servo r+

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 29d1cf6 has been approved by cbrewster

@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 29d1cf6 with merge 1d8283e...

@bors-servo

Copy link
Copy Markdown
Contributor

💔 Test failed - linux-rel-css

@KiChjang

KiChjang commented May 7, 2018

Copy link
Copy Markdown
Contributor

Looks like we have a new passing test!

{"status": "PASS", "group": "default", "message": null, "stack": null, "subtest": "font-weight transition", "test": "/css/css-fonts/variations/font-weight-interpolation.html", "line": 49827, "action": "test_result", "expected": "TIMEOUT"}

@KiChjang

KiChjang commented May 7, 2018

Copy link
Copy Markdown
Contributor

Wait sorry, false alarm, that's #20760. I don't think beforeunloadevent affects that test...

@cbrewster

Copy link
Copy Markdown
Contributor

@bors-servo

Copy link
Copy Markdown
Contributor

⚡ Previous build results for android, arm32, arm64, linux-dev, linux-rel-wpt, mac-dev-unit, mac-rel-css1, mac-rel-css2, mac-rel-wpt1, mac-rel-wpt3, windows-msvc-dev are reusable. Rebuilding only linux-rel-css, mac-rel-wpt2, mac-rel-wpt4...

@bors-servo

Copy link
Copy Markdown
Contributor

☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css1, mac-rel-css2, mac-rel-wpt1, mac-rel-wpt2, mac-rel-wpt3, mac-rel-wpt4, windows-msvc-dev
Approved by: cbrewster
Pushing 1d8283e to master...

@cbrewster

Copy link
Copy Markdown
Contributor

🎉 Thanks for your work on this @gterzian!

@gterzian

gterzian commented May 8, 2018

Copy link
Copy Markdown
Member Author

@cbrewster thanks for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-tests-failed The changes caused existing tests to fail.

Projects

None yet

8 participants