Bug 221771

Summary: [GTK][WPE] Signal "window-object-cleared" not emitted unless frame js context is get before
Product: WebKit Reporter: Adrian Perez <aperez>
Component: WebKit APIAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: berto, cgarcia, ews-watchlist, gustavo, mcatanzaro, psaavedra, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Local Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Example web process extension source
none
Patch mcatanzaro: review+

Description Adrian Perez 2021-02-11 12:33:27 PST
Created attachment 420028 [details]
Example web process extension source

Using a custom WebKitScriptWorld in a web process extension never triggers
the “window-object-cleared” signal. This can be verified with a simple web
process extension like the attached one (“ext.c”).

To reproduce the issue:

 1. Build the example extension:

      $CC -shared -o libext.so ext.c \
          $(pkg-config --libs --cflags wpe-web-extension-1.0)

 2. The run Cog passing the path to the directory containing the built
    “libext.so” file:
 
      cog -P fdo --web-extensions-dir="$(pwd)" ddg.gg

The expected (correct) output should include the following two lines:

   ** Message: 19:17:26.517: --> on_window_object_cleared
   ** Message: 19:17:26.517: <-- on_window_object_cleared

Building the extension with “-DHACK_FOR_CUSTOM_SCRIPT_WORLD” will use a
workaround that GNOME Web is currently using, see:

  https://gitlab.gnome.org/GNOME/epiphany/-/blob/8f833666c384a9c9f5d376ff15595e8bbece90a3/embed/web-process-extension/ephy-web-process-extension.c#L234

Current trunk and stable versions of WebKit (2.30.x, both GTK and WPE ports)
do *not* need the workaround when using the default WebKitScriptWorld.
Comment 1 Carlos Garcia Campos 2021-06-04 06:57:02 PDT
This is happening for default script world too.
Comment 2 Carlos Garcia Campos 2021-06-04 07:03:20 PDT
Created attachment 430573 [details]
Patch
Comment 3 EWS Watchlist 2021-06-04 07:04:10 PDT
Thanks for the patch. If this patch contains new public API please make sure it follows the guidelines for new WebKit2 GTK+ API. See https://trac.webkit.org/wiki/WebKitGTK/AddingNewWebKit2API
Comment 4 Carlos Garcia Campos 2021-06-07 01:21:13 PDT
Committed r278548 (238546@main): <https://commits.webkit.org/238546@main>
Comment 5 Radar WebKit Bug Importer 2021-06-07 01:22:17 PDT
<rdar://problem/78938532>