Bug 196478

Summary: [WK2] Add support for Window's beforeprint / afterprint events
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: DOMAssignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, anderson.calvin1, commit-queue, dbates, esprehn+autocc, ews-watchlist, ggaren, gyuyoung.kim, Hironori.Fujii, kangil.han, kondapallykalyan, rniwa, sroberts, webkit-bot-watchers-bugzilla, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
URL: https://html.spec.whatwg.org/#dom-print
See Also: https://bugs.webkit.org/show_bug.cgi?id=196654
Attachments:
Description Flags
Patch
none
Patch
none
Patch none

Description Chris Dumez 2019-04-01 20:03:33 PDT
Add support for Window's beforeprint / afterprint events as per:
- https://html.spec.whatwg.org/#dom-print

Blink and Gecko already support this.
Comment 1 Chris Dumez 2019-04-01 20:10:32 PDT
Created attachment 366463 [details]
Patch
Comment 2 Alex Christensen 2019-04-02 10:46:26 PDT
Comment on attachment 366463 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=366463&action=review

> Tools/WebKitTestRunner/TestController.cpp:268
> +    WKPageBeginPrinting(page, frame, WKPrintInfo { 1.0, 21.0, 29.7 });
> +    WKPageEndPrinting(page);

The definition of these is inside #if PLATFORM(COCOA).  I don't see any reason why.
Comment 3 Chris Dumez 2019-04-02 11:41:26 PDT
(In reply to Alex Christensen from comment #2)
> Comment on attachment 366463 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=366463&action=review
> 
> > Tools/WebKitTestRunner/TestController.cpp:268
> > +    WKPageBeginPrinting(page, frame, WKPrintInfo { 1.0, 21.0, 29.7 });
> > +    WKPageEndPrinting(page);
> 
> The definition of these is inside #if PLATFORM(COCOA).  I don't see any
> reason why.

Indeed, this was not intentional.
Comment 4 Chris Dumez 2019-04-02 11:46:30 PDT
Created attachment 366515 [details]
Patch
Comment 5 Chris Dumez 2019-04-02 12:41:27 PDT
Created attachment 366526 [details]
Patch
Comment 6 WebKit Commit Bot 2019-04-02 14:43:30 PDT
Comment on attachment 366526 [details]
Patch

Clearing flags on attachment: 366526

Committed r243762: <https://trac.webkit.org/changeset/243762>
Comment 7 WebKit Commit Bot 2019-04-02 14:43:32 PDT
All reviewed patches have been landed.  Closing bug.
Comment 8 Radar WebKit Bug Importer 2019-04-02 14:44:20 PDT
<rdar://problem/49535124>
Comment 9 Fujii Hironori 2019-04-02 18:58:16 PDT
Committed r243783: <https://trac.webkit.org/changeset/243783>
Comment 10 Shawn Roberts 2019-04-05 09:49:38 PDT
It looks like changes in https://trac.webkit.org/changeset/243762/webkit is causing the following layout test to crash in iOS Simulator Debug

editing/execCommand/print.html

Is crashing 100% of the time locally and on the bots. Does not happen in prior revisions.

Reproduced with:

run-webkit-tests editing/execCommand/print.html --iterations 5 -f --debug --ios-simulator

Crash Log:

https://build.webkit.org/results/Apple%20iOS%2012%20Simulator%20Debug%20WK2%20(Tests)/r243933%20(3157)/editing/execCommand/print-crash-log.txt

Same crash locally.
Comment 11 Chris Dumez 2019-04-05 09:55:28 PDT
(In reply to Shawn Roberts from comment #10)
> It looks like changes in https://trac.webkit.org/changeset/243762/webkit is
> causing the following layout test to crash in iOS Simulator Debug
> 
> editing/execCommand/print.html
> 
> Is crashing 100% of the time locally and on the bots. Does not happen in
> prior revisions.
> 
> Reproduced with:
> 
> run-webkit-tests editing/execCommand/print.html --iterations 5 -f --debug
> --ios-simulator
> 
> Crash Log:
> 
> https://build.webkit.org/results/
> Apple%20iOS%2012%20Simulator%20Debug%20WK2%20(Tests)/r243933%20(3157)/
> editing/execCommand/print-crash-log.txt
> 
> Same crash locally.

Probably a side effect of calling beginPrinting() in WebKitTestRunner. I guess it uncovered a bug.
Comment 12 Chris Dumez 2019-04-05 09:58:58 PDT
(In reply to Chris Dumez from comment #11)
> (In reply to Shawn Roberts from comment #10)
> > It looks like changes in https://trac.webkit.org/changeset/243762/webkit is
> > causing the following layout test to crash in iOS Simulator Debug
> > 
> > editing/execCommand/print.html
> > 
> > Is crashing 100% of the time locally and on the bots. Does not happen in
> > prior revisions.
> > 
> > Reproduced with:
> > 
> > run-webkit-tests editing/execCommand/print.html --iterations 5 -f --debug
> > --ios-simulator
> > 
> > Crash Log:
> > 
> > https://build.webkit.org/results/
> > Apple%20iOS%2012%20Simulator%20Debug%20WK2%20(Tests)/r243933%20(3157)/
> > editing/execCommand/print-crash-log.txt
> > 
> > Same crash locally.
> 
> Probably a side effect of calling beginPrinting() in WebKitTestRunner. I
> guess it uncovered a bug.

Ryosuke is more familiar with this code:
#ifndef NDEBUG
    // we should always be able to make the affinity DOWNSTREAM, because going previous from an
    // UPSTREAM position can never yield another UPSTREAM position (unless line wrap length is 0!).
    if (prev.isNotNull() && m_affinity == UPSTREAM) {
        VisiblePosition temp = prev;
        temp.setAffinity(UPSTREAM);
        ASSERT(inSameLine(temp, prev));
    }
#endif

We hit this assertion in VisiblePosition::previous().
Comment 13 Ryosuke Niwa 2019-04-05 13:09:17 PDT
(In reply to Chris Dumez from comment #12)
> (In reply to Chris Dumez from comment #11)
> > (In reply to Shawn Roberts from comment #10)
> > > It looks like changes in https://trac.webkit.org/changeset/243762/webkit is
> > > causing the following layout test to crash in iOS Simulator Debug
> > > 
> > > editing/execCommand/print.html
> > > 
> > > Is crashing 100% of the time locally and on the bots. Does not happen in
> > > prior revisions.
> > > 
> > > Reproduced with:
> > > 
> > > run-webkit-tests editing/execCommand/print.html --iterations 5 -f --debug
> > > --ios-simulator
> > > 
> > > Crash Log:
> > > 
> > > https://build.webkit.org/results/
> > > Apple%20iOS%2012%20Simulator%20Debug%20WK2%20(Tests)/r243933%20(3157)/
> > > editing/execCommand/print-crash-log.txt
> > > 
> > > Same crash locally.
> > 
> > Probably a side effect of calling beginPrinting() in WebKitTestRunner. I
> > guess it uncovered a bug.
> 
> Ryosuke is more familiar with this code:
> #ifndef NDEBUG
>     // we should always be able to make the affinity DOWNSTREAM, because
> going previous from an
>     // UPSTREAM position can never yield another UPSTREAM position (unless
> line wrap length is 0!).
>     if (prev.isNotNull() && m_affinity == UPSTREAM) {
>         VisiblePosition temp = prev;
>         temp.setAffinity(UPSTREAM);
>         ASSERT(inSameLine(temp, prev));
>     }
> #endif
> 
> We hit this assertion in VisiblePosition::previous().

We're not gonna be able to fix such an assertion anytime soon. I suggest we skip the test in debug builds for now.
Comment 14 Chris Dumez 2022-02-11 11:33:57 PST
*** Bug 19937 has been marked as a duplicate of this bug. ***