WebKit Bugzilla
Attachment 368435 Details for
Bug 197270
: [WPE][GTK] Add webkit_frame_get_id() API
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-197270-20190428161425.patch (text/plain), 11.92 KB, created by
Michael Catanzaro
on 2019-04-28 14:14:26 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Michael Catanzaro
Created:
2019-04-28 14:14:26 PDT
Size:
11.92 KB
patch
obsolete
>Subversion Revision: 244723 >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 3433e25307281486aca95a901ae873c894eb6e03..a3a2da3250f9ccb3b145f2b29cebce2421b9acf2 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,19 @@ >+2019-04-28 Michael Catanzaro <mcatanzaro@igalia.com> >+ >+ [WPE][GTK] Add webkit_frame_get_id() API >+ https://bugs.webkit.org/show_bug.cgi?id=197270 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ It's as simple as can be: just an API to return the ID of a frame. >+ >+ * UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt: >+ * WebProcess/InjectedBundle/API/glib/WebKitFrame.cpp: >+ (webkit_frame_get_id): >+ * WebProcess/InjectedBundle/API/gtk/WebKitFrame.h: >+ * WebProcess/InjectedBundle/API/wpe/WebKitFrame.h: >+ * WebProcess/InjectedBundle/API/wpe/docs/wpe-webextensions-1.0-sections.txt: >+ > 2019-04-27 Chris Dumez <cdumez@apple.com> > > Improve safety of MachMessage class >diff --git a/Source/WebKit/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt b/Source/WebKit/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt >index 23eeaa62074d05d2db61245b806ab38d71f8cecb..df585a2e6deea3894acf943093ce3a17b0735272 100644 >--- a/Source/WebKit/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt >+++ b/Source/WebKit/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt >@@ -1599,6 +1599,7 @@ webkit_web_editor_get_type > <SECTION> > <FILE>WebKitFrame</FILE> > WebKitFrame >+webkit_frame_get_id > webkit_frame_is_main_frame > webkit_frame_get_uri > webkit_frame_get_javascript_global_context >diff --git a/Source/WebKit/WebProcess/InjectedBundle/API/glib/WebKitFrame.cpp b/Source/WebKit/WebProcess/InjectedBundle/API/glib/WebKitFrame.cpp >index 21a3f636e2a13e7560051e9b6044e1c875dd189f..d09360b3b028387124ccb766e9f21a7f9b1bc7e4 100644 >--- a/Source/WebKit/WebProcess/InjectedBundle/API/glib/WebKitFrame.cpp >+++ b/Source/WebKit/WebProcess/InjectedBundle/API/glib/WebKitFrame.cpp >@@ -58,6 +58,23 @@ WebFrame* webkitFrameGetWebFrame(WebKitFrame* frame) > return frame->priv->webFrame.get(); > } > >+/** >+ * webkit_frame_get_id: >+ * @frame: a #WebKitFrame >+ * >+ * Gets the process-unique identifier of this #WebKitFrame. No other >+ * frame in the same web process will have the same ID; however, frames >+ * in other web processes may. >+ * >+ * Returns: the identifier of @frame >+ * >+ * Since: 2.26 >+ */ >+guint64 webkit_frame_get_id(WebKitFrame* frame) >+{ >+ return frame->priv->webFrame->frameID(); >+} >+ > /** > * webkit_frame_is_main_frame: > * @frame: a #WebKitFrame >diff --git a/Source/WebKit/WebProcess/InjectedBundle/API/gtk/WebKitFrame.h b/Source/WebKit/WebProcess/InjectedBundle/API/gtk/WebKitFrame.h >index a310060a3824cb5ec6840040e4def0152c7372a3..42f161b2b153e7d940c6de57d57386d1f656f5c4 100644 >--- a/Source/WebKit/WebProcess/InjectedBundle/API/gtk/WebKitFrame.h >+++ b/Source/WebKit/WebProcess/InjectedBundle/API/gtk/WebKitFrame.h >@@ -57,6 +57,9 @@ struct _WebKitFrameClass { > WEBKIT_API GType > webkit_frame_get_type (void); > >+WEBKIT_API guint64 >+webkit_frame_get_id (WebKitFrame *frame); >+ > WEBKIT_API gboolean > webkit_frame_is_main_frame (WebKitFrame *frame); > >diff --git a/Source/WebKit/WebProcess/InjectedBundle/API/wpe/WebKitFrame.h b/Source/WebKit/WebProcess/InjectedBundle/API/wpe/WebKitFrame.h >index a3c6394dad1f075b74ead3c6ad3c9e618e9d8471..6a79c0306bef93888ca2393bd50e09378de16722 100644 >--- a/Source/WebKit/WebProcess/InjectedBundle/API/wpe/WebKitFrame.h >+++ b/Source/WebKit/WebProcess/InjectedBundle/API/wpe/WebKitFrame.h >@@ -56,6 +56,9 @@ struct _WebKitFrameClass { > WEBKIT_API GType > webkit_frame_get_type (void); > >+WEBKIT_API guint64 >+webkit_frame_get_id (WebKitFrame *frame); >+ > WEBKIT_API gboolean > webkit_frame_is_main_frame (WebKitFrame *frame); > >diff --git a/Source/WebKit/WebProcess/InjectedBundle/API/wpe/docs/wpe-webextensions-1.0-sections.txt b/Source/WebKit/WebProcess/InjectedBundle/API/wpe/docs/wpe-webextensions-1.0-sections.txt >index a1d6844ddcfec6690d8d1412b6aaa61c1f050a24..e448296d9fa77a11aa60183dff020d14a80df98f 100644 >--- a/Source/WebKit/WebProcess/InjectedBundle/API/wpe/docs/wpe-webextensions-1.0-sections.txt >+++ b/Source/WebKit/WebProcess/InjectedBundle/API/wpe/docs/wpe-webextensions-1.0-sections.txt >@@ -76,6 +76,7 @@ webkit_web_editor_get_type > <SECTION> > <FILE>WebKitFrame</FILE> > WebKitFrame >+webkit_frame_get_id > webkit_frame_is_main_frame > webkit_frame_get_uri > webkit_frame_get_js_context >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 9c307d39eb8a622dc232f8b9ac7ee4ed908227fb..fced3c1b8dda0d35dc2b3dbbee4ce55f5ca394f6 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,24 @@ >+2019-04-28 Michael Catanzaro <mcatanzaro@igalia.com> >+ >+ [WPE][GTK] Add webkit_frame_get_id() API >+ https://bugs.webkit.org/show_bug.cgi?id=197270 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ This was hard, but I added a test to verify that two different WebKitFrames of the same >+ WebKitWebPage return two different frame IDs. >+ >+ * TestWebKitAPI/Tests/WebKitGLib/FrameTest.cpp: >+ (WebKitSubframeTest::create): >+ (WebKitSubframeTest::willSubmitFormCallback): >+ (WebKitSubframeTest::testSubframe): >+ (registerTests): >+ * TestWebKitAPI/Tests/WebKitGLib/TestFrame.cpp: >+ (testWebKitFrameSubframe): >+ (beforeAll): >+ * TestWebKitAPI/Tests/WebKitGLib/resources/form-in-frame.html: Added. >+ * TestWebKitAPI/Tests/WebKitGLib/resources/webkitglib-tests.gresource.xml: >+ > 2019-04-27 Chris Dumez <cdumez@apple.com> > > [WKTR] Move test timeout handling to the UIProcess >diff --git a/Tools/TestWebKitAPI/Tests/WebKitGLib/FrameTest.cpp b/Tools/TestWebKitAPI/Tests/WebKitGLib/FrameTest.cpp >index 2e67c0a7a32f221fe0d62b7ad44e4201ac1023c2..980215b7ff23e033a51337be17b0642d2a72edb9 100644 >--- a/Tools/TestWebKitAPI/Tests/WebKitGLib/FrameTest.cpp >+++ b/Tools/TestWebKitAPI/Tests/WebKitGLib/FrameTest.cpp >@@ -131,6 +131,49 @@ private: > return true; > } > >+ static void willSubmitFormCallback(WebKitWebPage* page, WebKitDOMElement*, WebKitFormSubmissionStep, WebKitFrame* sourceFrame, WebKitFrame*, GPtrArray*, GPtrArray*, gpointer userData) >+ { >+ // The form is submitted from a subframe. It should have a different ID than the main frame. >+ WebKitFrame* mainFrame = webkit_web_page_get_main_frame(page); >+ g_assert_cmpuint(webkit_frame_get_id(mainFrame), !=, webkit_frame_get_id(sourceFrame)); >+ >+ auto* test = static_cast<WebKitFrameTest*>(userData); >+ g_main_loop_quit(test->m_mainLoop.get()); >+ } >+ >+ bool testSubframe(WebKitWebPage* page) >+ { >+ WebKitFrame* mainFrame = webkit_web_page_get_main_frame(page); >+ g_assert_true(WEBKIT_IS_FRAME(mainFrame)); >+ >+ GRefPtr<JSCContext> jsContext = adoptGRef(webkit_frame_get_js_context(mainFrame)); >+ g_assert_true(JSC_IS_CONTEXT(jsContext.get())); >+ assertObjectIsDeletedWhenTestFinishes(G_OBJECT(jsContext.get())); >+ >+ GRefPtr<JSCValue> jsParentDocument = adoptGRef(jsc_context_get_value(jsContext.get(), "document")); >+ g_assert_true(JSC_IS_VALUE(jsParentDocument.get())); >+ assertObjectIsDeletedWhenTestFinishes(G_OBJECT(jsParentDocument.get())); >+ >+ GRefPtr<JSCValue> subframe = adoptGRef(jsc_value_object_invoke_method(jsParentDocument.get(), "getElementById", G_TYPE_STRING, "frame", G_TYPE_NONE)); >+ g_assert_true(JSC_IS_VALUE(subframe.get())); >+ assertObjectIsDeletedWhenTestFinishes(G_OBJECT(subframe.get())); >+ >+ GRefPtr<JSCValue> contentWindow = adoptGRef(jsc_value_object_get_property(subframe.get(), "contentWindow")); >+ g_assert_true(JSC_IS_VALUE(contentWindow.get())); >+ assertObjectIsDeletedWhenTestFinishes(G_OBJECT(contentWindow.get())); >+ >+ GRefPtr<JSCValue> undefined = adoptGRef(jsc_value_object_invoke_method(contentWindow.get(), "postMessage", G_TYPE_STRING, "submit the form!", G_TYPE_STRING, "*", G_TYPE_NONE)); >+ g_assert_true(JSC_IS_VALUE(undefined.get())); >+ g_assert_true(jsc_value_is_undefined(undefined.get())); >+ >+ g_signal_connect(page, "will-submit-form", reinterpret_cast<GCallback>(willSubmitFormCallback), this); >+ >+ m_mainLoop = adoptGRef(g_main_loop_new(nullptr, FALSE)); >+ g_main_loop_run(m_mainLoop.get()); >+ >+ return true; >+ } >+ > bool runTest(const char* testName, WebKitWebPage* page) override > { > if (!strcmp(testName, "main-frame")) >@@ -141,10 +184,14 @@ private: > return testJavaScriptContext(page); > if (!strcmp(testName, "javascript-values")) > return testJavaScriptValues(page); >+ if (!strcmp(testName, "subframe")) >+ return testSubframe(page); > > g_assert_not_reached(); > return false; > } >+ >+ GRefPtr<GMainLoop> m_mainLoop; > }; > > static void __attribute__((constructor)) registerTests() >@@ -153,4 +200,5 @@ static void __attribute__((constructor)) registerTests() > REGISTER_TEST(WebKitFrameTest, "WebKitFrame/uri"); > REGISTER_TEST(WebKitFrameTest, "WebKitFrame/javascript-context"); > REGISTER_TEST(WebKitFrameTest, "WebKitFrame/javascript-values"); >+ REGISTER_TEST(WebKitFrameTest, "WebKitFrame/subframe"); > } >diff --git a/Tools/TestWebKitAPI/Tests/WebKitGLib/TestFrame.cpp b/Tools/TestWebKitAPI/Tests/WebKitGLib/TestFrame.cpp >index f6d297f2e49e8b42ee383b182ed4d8b84751515f..65dcd92bd9a6ab96835b05c1835675e1962dd417 100644 >--- a/Tools/TestWebKitAPI/Tests/WebKitGLib/TestFrame.cpp >+++ b/Tools/TestWebKitAPI/Tests/WebKitGLib/TestFrame.cpp >@@ -42,12 +42,19 @@ static void testWebKitFrameJavaScriptValues(WebViewTest* test, gconstpointer) > g_assert_true(test->runWebProcessTest("WebKitFrame", "javascript-values", testHTML)); > } > >+static void testWebKitFrameSubframe(WebViewTest* test, gconstpointer) >+{ >+ static const char* testHTML = "<html><body><iframe src='resource:///org/webkit/glib/tests/form-in-frame.html' id='frame'></iframe></body></html>"; >+ g_assert_true(test->runWebProcessTest("WebKitFrame", "subframe", testHTML)); >+} >+ > void beforeAll() > { > WebViewTest::add("WebKitFrame", "main-frame", testWebKitFrameMainFrame); > WebViewTest::add("WebKitFrame", "uri", testWebKitFrameURI); > WebViewTest::add("WebKitFrame", "javascript-context", testWebKitFrameJavaScriptContext); > WebViewTest::add("WebKitFrame", "javascript-values", testWebKitFrameJavaScriptValues); >+ WebViewTest::add("WebKitFrame", "subframe", testWebKitFrameSubframe); > } > > void afterAll() >diff --git a/Tools/TestWebKitAPI/Tests/WebKitGLib/resources/form-in-frame.html b/Tools/TestWebKitAPI/Tests/WebKitGLib/resources/form-in-frame.html >new file mode 100644 >index 0000000000000000000000000000000000000000..0ec7d1693d9cfbdb88e5f5b7cfc45d81dce99490 >--- /dev/null >+++ b/Tools/TestWebKitAPI/Tests/WebKitGLib/resources/form-in-frame.html >@@ -0,0 +1,8 @@ >+<form id='form'> >+</form> >+<script> >+ window.addEventListener('message', event => { >+ if (event.data === 'submit the form!') >+ document.getElementById('form').submit(); >+ }, false); >+</script> >diff --git a/Tools/TestWebKitAPI/Tests/WebKitGLib/resources/webkitglib-tests.gresource.xml b/Tools/TestWebKitAPI/Tests/WebKitGLib/resources/webkitglib-tests.gresource.xml >index ee571d788c0e34bd7b301a27899a676b7396201d..ae642a7b32879d1d0434801bb5da923e8ccac873 100644 >--- a/Tools/TestWebKitAPI/Tests/WebKitGLib/resources/webkitglib-tests.gresource.xml >+++ b/Tools/TestWebKitAPI/Tests/WebKitGLib/resources/webkitglib-tests.gresource.xml >@@ -2,6 +2,7 @@ > <gresources> > <gresource prefix="/org/webkit/glib/tests/"> > <file alias="boring.html">Tools/TestWebKitAPI/Tests/WebKitGLib/resources/boring.html</file> >+ <file alias="form-in-frame.html">Tools/TestWebKitAPI/Tests/WebKitGLib/resources/form-in-frame.html</file> > <file alias="link-title.js">Tools/TestWebKitAPI/Tests/WebKitGLib/resources/link-title.js</file> > </gresource> > </gresources>
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
cgarcia
:
review+
cgarcia
:
commit-queue-
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 197270
:
368208
|
368431
| 368435