Skip to content

Commit ae93002

Browse files
committed
Web Inspector: Implement frameURL option for devtools.inspectedWindow.eval command
https://bugs.webkit.org/show_bug.cgi?id=222568 Reviewed by Devin Rousso. Source/WebInspectorUI: New test: Tools/TestWebKitAPI/Tests/WebKitCocoa/WKInspectorExtension.mm Add support for evaluating script from an extension in a specific frame on the page by referring to it by the frame's URL. Frame URLs are matched in three steps, first looking for an exact URL match, including query parameters and fragment identifier. If no match is found and the provided `options.frameURL` does not have any fragment identifier or query parameters, a check is then made against each known frame again, this time excluding their fragment identifier. If that check still fails to find a frame for the URL, we perform one more pass, this time excluding the fragment identifier and query parameters for each known frame. * UserInterface/Controllers/WebInspectorExtensionController.js: (WI.WebInspectorExtensionController.prototype.evaluateScriptForExtension): (WI.WebInspectorExtensionController.prototype.reloadForExtension): - Drive-by removal of trailing spaces. (WI.WebInspectorExtensionController.prototype._frameForFrameURL): Source/WebKit: New test: Tools/TestWebKitAPI/Tests/WebKitCocoa/WKInspectorExtension.mm Correct the API to indicate that `frameURL` and `contextSecurityOrigin` are nullable parameters. * UIProcess/API/Cocoa/_WKInspectorExtension.h: Tools: Add test coverage for evaluating script on an inspected page from an extension, including evaluating on an inner frame. * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WebKitCocoa/WKInspectorExtension.mm: (TEST): * TestWebKitAPI/Tests/WebKitCocoa/WKInspectorExtensionEvaluateScriptOnPage.html: Added. * TestWebKitAPI/Tests/WebKitCocoa/WKInspectorExtensionEvaluateScriptOnPageInnerFrame.html: Added. Canonical link: https://commits.webkit.org/246008@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@287979 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 23258a6 commit ae93002

9 files changed

Lines changed: 249 additions & 10 deletions

File tree

Source/WebInspectorUI/ChangeLog

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
2022-01-13 Patrick Angle <pangle@apple.com>
2+
3+
Web Inspector: Implement `frameURL` option for `devtools.inspectedWindow.eval` command
4+
https://bugs.webkit.org/show_bug.cgi?id=222568
5+
6+
Reviewed by Devin Rousso.
7+
8+
New test: Tools/TestWebKitAPI/Tests/WebKitCocoa/WKInspectorExtension.mm
9+
10+
Add support for evaluating script from an extension in a specific frame on the page by referring to it by the
11+
frame's URL. Frame URLs are matched in three steps, first looking for an exact URL match, including query
12+
parameters and fragment identifier. If no match is found and the provided `options.frameURL` does not have any
13+
fragment identifier or query parameters, a check is then made against each known frame again, this time
14+
excluding their fragment identifier. If that check still fails to find a frame for the URL, we perform one more
15+
pass, this time excluding the fragment identifier and query parameters for each known frame.
16+
17+
* UserInterface/Controllers/WebInspectorExtensionController.js:
18+
(WI.WebInspectorExtensionController.prototype.evaluateScriptForExtension):
19+
(WI.WebInspectorExtensionController.prototype.reloadForExtension):
20+
- Drive-by removal of trailing spaces.
21+
(WI.WebInspectorExtensionController.prototype._frameForFrameURL):
22+
123
2022-01-12 Elliott Williams <emw@apple.com>
224

325
[Xcode] Configure each project for the legacy build system

Source/WebInspectorUI/UserInterface/Controllers/WebInspectorExtensionController.js

Lines changed: 50 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,10 @@ WI.WebInspectorExtensionController = class WebInspectorExtensionController exten
133133
return WI.WebInspectorExtension.ErrorCode.InvalidRequest;
134134
}
135135

136-
// FIXME: <rdar://problem/74180355> implement execution context selection options
137-
if (frameURL) {
138-
WI.reportInternalError("evaluateScriptForExtension: the 'frameURL' option is not yet implemented.");
139-
return WI.WebInspectorExtension.ErrorCode.NotImplemented;
136+
let frame = this._frameForFrameURL(frameURL);
137+
if (!frame) {
138+
WI.reportInternalError("evaluateScriptForExtension: No frame matched provided frameURL: " + frameURL);
139+
return WI.WebInspectorExtension.ErrorCode.InvalidRequest;
140140
}
141141

142142
if (contextSecurityOrigin) {
@@ -149,7 +149,12 @@ WI.WebInspectorExtensionController = class WebInspectorExtensionController exten
149149
return WI.WebInspectorExtension.ErrorCode.NotImplemented;
150150
}
151151

152-
let evaluationContext = WI.runtimeManager.activeExecutionContext;
152+
let evaluationContext = frame.pageExecutionContext;
153+
if (!evaluationContext) {
154+
WI.reportInternalError("evaluateScriptForExtension: No 'pageExecutionContext' was present for frame with URL: " + frame.url);
155+
return WI.WebInspectorExtension.ErrorCode.ContextDestroyed;
156+
}
157+
153158
return evaluationContext.target.RuntimeAgent.evaluate.invoke({
154159
expression: scriptSource,
155160
objectGroup: "extension-evaluation",
@@ -165,7 +170,7 @@ WI.WebInspectorExtensionController = class WebInspectorExtensionController exten
165170
return wasThrown ? {"error": resultOrError.description} : {"result": value};
166171
}).catch((error) => error.description);
167172
}
168-
173+
169174
reloadForExtension(extensionID, {ignoreCache, userAgent, injectedScript} = {})
170175
{
171176
let extension = this._extensionForExtensionIDMap.get(extensionID);
@@ -184,14 +189,14 @@ WI.WebInspectorExtensionController = class WebInspectorExtensionController exten
184189
WI.reportInternalError("reloadForExtension: the 'injectedScript' option is not yet implemented.");
185190
return WI.WebInspectorExtension.ErrorCode.NotImplemented;
186191
}
187-
192+
188193
let target = WI.assumingMainTarget();
189194
if (!target.hasCommand("Page.reload"))
190195
return WI.WebInspectorExtension.ErrorCode.InvalidRequest;
191-
196+
192197
return target.PageAgent.reload.invoke({ignoreCache});
193198
}
194-
199+
195200
showExtensionTab(extensionTabID, options = {})
196201
{
197202
let tabContentView = this._extensionTabContentViewForExtensionTabIDMap.get(extensionTabID);
@@ -393,6 +398,42 @@ WI.WebInspectorExtensionController = class WebInspectorExtensionController exten
393398
return {anchorTabType, anchorTabIndex, distanceFromAnchorTab};
394399
}
395400

401+
_frameForFrameURL(frameURL)
402+
{
403+
if (!frameURL)
404+
return WI.networkManager.mainFrame;
405+
406+
function findFrame(frameURL, adjustKnownFrameURL) {
407+
return WI.networkManager.frames.find((knownFrame) => {
408+
let knownFrameURL = new URL(knownFrame.url);
409+
adjustKnownFrameURL?.(knownFrameURL);
410+
return knownFrameURL.toString() === frameURL;
411+
});
412+
}
413+
414+
let frame = findFrame(frameURL);
415+
if (frame)
416+
return frame;
417+
418+
let frameURLParts = new URL(frameURL);
419+
if (frameURLParts.hash.length)
420+
return null;
421+
422+
frame = findFrame(frameURL, (knownFrameURL) => {
423+
knownFrameURL.hash = "";
424+
});
425+
if (frame)
426+
return frame;
427+
428+
if (frameURLParts.search.length)
429+
return null;
430+
431+
return findFrame(frameURL, (knownFrameURL) => {
432+
knownFrameURL.hash = "";
433+
knownFrameURL.search = "";
434+
});
435+
}
436+
396437
_handleMainResourceDidChange(event)
397438
{
398439
if (!event.target.isMainFrame())

Source/WebKit/ChangeLog

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
2022-01-13 Patrick Angle <pangle@apple.com>
2+
3+
Web Inspector: Implement `frameURL` option for `devtools.inspectedWindow.eval` command
4+
https://bugs.webkit.org/show_bug.cgi?id=222568
5+
6+
Reviewed by Devin Rousso.
7+
8+
New test: Tools/TestWebKitAPI/Tests/WebKitCocoa/WKInspectorExtension.mm
9+
10+
Correct the API to indicate that `frameURL` and `contextSecurityOrigin` are nullable parameters.
11+
12+
* UIProcess/API/Cocoa/_WKInspectorExtension.h:
13+
114
2022-01-12 John Wilander <wilander@apple.com>
215

316
PCM: Same-site triggering events should support ephemeral measurement

Source/WebKit/UIProcess/API/Cocoa/_WKInspectorExtension.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ WK_CLASS_AVAILABLE(macos(12.0))
6363
* scriptSource is treated as a top-level evaluation. By default, the script is evaluated in the inspected page's script context.
6464
* The inspected page ultimately controls its execution context and the result of this evaluation. Thus, the result shall be treated as untrusted input.
6565
*/
66-
- (void)evaluateScript:(NSString *)scriptSource frameURL:(NSURL *)frameURL contextSecurityOrigin:(NSURL *)contextSecurityOrigin useContentScriptContext:(BOOL)useContentScriptContext completionHandler:(void(^)(NSError * _Nullable, id result))completionHandler;
66+
- (void)evaluateScript:(NSString *)scriptSource frameURL:(NSURL * _Nullable)frameURL contextSecurityOrigin:(NSURL * _Nullable)contextSecurityOrigin useContentScriptContext:(BOOL)useContentScriptContext completionHandler:(void(^)(NSError * _Nullable, id result))completionHandler;
6767

6868
/**
6969
* @abstract Evaluates JavaScript in the context of a Web Inspector tab created by this _WKInspectorExtension.

Tools/ChangeLog

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
2022-01-13 Patrick Angle <pangle@apple.com>
2+
3+
Web Inspector: Implement `frameURL` option for `devtools.inspectedWindow.eval` command
4+
https://bugs.webkit.org/show_bug.cgi?id=222568
5+
6+
Reviewed by Devin Rousso.
7+
8+
Add test coverage for evaluating script on an inspected page from an extension, including evaluating on an inner
9+
frame.
10+
11+
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
12+
* TestWebKitAPI/Tests/WebKitCocoa/WKInspectorExtension.mm:
13+
(TEST):
14+
* TestWebKitAPI/Tests/WebKitCocoa/WKInspectorExtensionEvaluateScriptOnPage.html: Added.
15+
* TestWebKitAPI/Tests/WebKitCocoa/WKInspectorExtensionEvaluateScriptOnPageInnerFrame.html: Added.
16+
117
2022-01-12 Jonathan Bedard <jbedard@apple.com>
218

319
[EWS] Load contributors from stand-alone class

Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@
169169
2EB29D5E1F762DB90023A5F1 /* dump-datatransfer-types.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2EB29D5D1F762DA50023A5F1 /* dump-datatransfer-types.html */; };
170170
2EBD9D0A2134730D002DA758 /* video.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 07CD32F72065B72A0064A4BE /* video.html */; };
171171
2EC7034A26AF5E88002B2D37 /* KeyboardEventTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2EC7034926AF5E88002B2D37 /* KeyboardEventTests.mm */; };
172+
2ED88823277125AB00DB7E99 /* WKInspectorExtensionEvaluateScriptOnPage.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2ED8882127711F1200DB7E99 /* WKInspectorExtensionEvaluateScriptOnPage.html */; };
173+
2ED88824277125AB00DB7E99 /* WKInspectorExtensionEvaluateScriptOnPageInnerFrame.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2ED888222771203A00DB7E99 /* WKInspectorExtensionEvaluateScriptOnPageInnerFrame.html */; };
172174
2EFF06C31D88621E0004BB30 /* large-video-offscreen.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2EFF06C21D8862120004BB30 /* large-video-offscreen.html */; };
173175
2EFF06C51D8867760004BB30 /* change-video-source-on-click.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2EFF06C41D8867700004BB30 /* change-video-source-on-click.html */; };
174176
2EFF06C71D886A580004BB30 /* change-video-source-on-end.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2EFF06C61D886A560004BB30 /* change-video-source-on-end.html */; };
@@ -1634,6 +1636,8 @@
16341636
CE14F1A4181873B0001C2705 /* WillPerformClientRedirectToURLCrash.html in Copy Resources */,
16351637
468F2F942368DAF100F4B864 /* window-open-then-document-open.html in Copy Resources */,
16361638
A5E2027515B21F6E00C13E14 /* WindowlessWebViewWithMedia.html in Copy Resources */,
1639+
2ED88823277125AB00DB7E99 /* WKInspectorExtensionEvaluateScriptOnPage.html in Copy Resources */,
1640+
2ED88824277125AB00DB7E99 /* WKInspectorExtensionEvaluateScriptOnPageInnerFrame.html in Copy Resources */,
16371641
);
16381642
name = "Copy Resources";
16391643
runOnlyForDeploymentPostprocessing = 0;
@@ -1857,6 +1861,8 @@
18571861
2EB29D5D1F762DA50023A5F1 /* dump-datatransfer-types.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "dump-datatransfer-types.html"; sourceTree = "<group>"; };
18581862
2EC7034926AF5E88002B2D37 /* KeyboardEventTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = KeyboardEventTests.mm; sourceTree = "<group>"; };
18591863
2ECFF5541D9B12F800B55394 /* NowPlayingControlsTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NowPlayingControlsTests.mm; sourceTree = "<group>"; };
1864+
2ED8882127711F1200DB7E99 /* WKInspectorExtensionEvaluateScriptOnPage.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = WKInspectorExtensionEvaluateScriptOnPage.html; sourceTree = "<group>"; };
1865+
2ED888222771203A00DB7E99 /* WKInspectorExtensionEvaluateScriptOnPageInnerFrame.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = WKInspectorExtensionEvaluateScriptOnPageInnerFrame.html; sourceTree = "<group>"; };
18601866
2EFF06C21D8862120004BB30 /* large-video-offscreen.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "large-video-offscreen.html"; sourceTree = "<group>"; };
18611867
2EFF06C41D8867700004BB30 /* change-video-source-on-click.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "change-video-source-on-click.html"; sourceTree = "<group>"; };
18621868
2EFF06C61D886A560004BB30 /* change-video-source-on-end.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "change-video-source-on-end.html"; sourceTree = "<group>"; };
@@ -4252,6 +4258,8 @@
42524258
51714EB31CF8C761004723C4 /* WebProcessKillIDBCleanup-2.html */,
42534259
5120C83B1E674E350025B250 /* WebsiteDataStoreCustomPaths.html */,
42544260
2E131C171D83A97E001BA36C /* wide-autoplaying-video-with-audio.html */,
4261+
2ED8882127711F1200DB7E99 /* WKInspectorExtensionEvaluateScriptOnPage.html */,
4262+
2ED888222771203A00DB7E99 /* WKInspectorExtensionEvaluateScriptOnPageInnerFrame.html */,
42554263
);
42564264
name = Resources;
42574265
sourceTree = "<group>";

Tools/TestWebKitAPI/Tests/WebKitCocoa/WKInspectorExtension.mm

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#import "DeprecatedGlobalValues.h"
3131
#import "TestCocoa.h"
3232
#import "TestInspectorURLSchemeHandler.h"
33+
#import "TestNavigationDelegate.h"
3334
#import "Utilities.h"
3435
#import <WebKit/WKPreferencesPrivate.h>
3536
#import <WebKit/WKWebViewPrivate.h>
@@ -382,4 +383,127 @@ - (void)inspectorExtension:(_WKInspectorExtension *)extension didHideTabWithIden
382383
TestWebKitAPI::Util::run(&pendingCallbackWasCalled);
383384
}
384385

386+
TEST(WKInspectorExtension, EvaluateScriptOnPage)
387+
{
388+
resetGlobalState();
389+
390+
auto webViewConfiguration = adoptNS([WKWebViewConfiguration new]);
391+
webViewConfiguration.get().preferences._developerExtrasEnabled = YES;
392+
auto webView = adoptNS([[WKWebView alloc] initWithFrame:CGRectMake(0, 0, 800, 600) configuration:webViewConfiguration.get()]);
393+
auto uiDelegate = adoptNS([UIDelegateForTestingInspectorExtension new]);
394+
auto navigationDelegate = adoptNS([[TestNavigationDelegate alloc] init]);
395+
396+
auto *testPageFileURL = [NSBundle.mainBundle URLForResource:@"WKInspectorExtensionEvaluateScriptOnPage" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"];
397+
398+
[webView setUIDelegate:uiDelegate.get()];
399+
[webView setNavigationDelegate:navigationDelegate.get()];
400+
[webView loadFileURL:testPageFileURL allowingReadAccessToURL:testPageFileURL.URLByDeletingLastPathComponent];
401+
[navigationDelegate waitForDidFinishNavigation];
402+
403+
[[webView _inspector] show];
404+
TestWebKitAPI::Util::run(&didAttachLocalInspectorCalled);
405+
406+
auto extensionID = [NSUUID UUID].UUIDString;
407+
auto extensionBundleIdentifier = @"org.webkit.TestWebKitAPI.FourthExtension";
408+
auto extensionDisplayName = @"FourthExtension";
409+
410+
// Register the test extension.
411+
pendingCallbackWasCalled = false;
412+
[[webView _inspector] registerExtensionWithID:extensionID extensionBundleIdentifier:extensionBundleIdentifier displayName:extensionDisplayName completionHandler:^(NSError *error, _WKInspectorExtension *extension) {
413+
EXPECT_NULL(error);
414+
EXPECT_NOT_NULL(extension);
415+
sharedInspectorExtension = extension;
416+
417+
pendingCallbackWasCalled = true;
418+
}];
419+
TestWebKitAPI::Util::run(&pendingCallbackWasCalled);
420+
421+
auto extensionDelegate = adoptNS([InspectorExtensionDelegateForTestingInspectorExtension new]);
422+
[sharedInspectorExtension setDelegate:extensionDelegate.get()];
423+
424+
// Create and show an extension tab.
425+
auto iconURL = [NSURL URLWithString:@"test-resource://FourthExtension/InspectorExtension-TabIcon-30x30.png"];
426+
auto sourceURL = [NSURL URLWithString:@"test-resource://FourthExtension/InspectorExtension-basic-tab.html"];
427+
428+
pendingCallbackWasCalled = false;
429+
[sharedInspectorExtension createTabWithName:@"FourthExtension-Tab" tabIconURL:iconURL sourceURL:sourceURL completionHandler:^(NSError *error, NSString *extensionTabIdentifier) {
430+
EXPECT_NULL(error);
431+
EXPECT_NOT_NULL(extensionTabIdentifier);
432+
sharedExtensionTabIdentifier = extensionTabIdentifier;
433+
434+
pendingCallbackWasCalled = true;
435+
}];
436+
TestWebKitAPI::Util::run(&pendingCallbackWasCalled);
437+
438+
pendingCallbackWasCalled = false;
439+
didShowExtensionTabWasCalled = false;
440+
[[webView _inspector] showExtensionTabWithIdentifier:sharedExtensionTabIdentifier.get() completionHandler:^(NSError *error) {
441+
EXPECT_NULL(error);
442+
443+
pendingCallbackWasCalled = true;
444+
}];
445+
TestWebKitAPI::Util::run(&pendingCallbackWasCalled);
446+
TestWebKitAPI::Util::run(&didShowExtensionTabWasCalled);
447+
448+
auto mainFrameSecretString = @"42-mainFrame";
449+
auto innerFrameSecretString = @"42-innerFrame";
450+
auto scriptSource = @"document.getElementById('secret').innerText";
451+
452+
// Test main frame evaluation.
453+
pendingCallbackWasCalled = false;
454+
[sharedInspectorExtension evaluateScript:scriptSource frameURL:nil contextSecurityOrigin:nil useContentScriptContext:false completionHandler:^(NSError *error, NSDictionary *result) {
455+
EXPECT_NULL(error);
456+
EXPECT_NOT_NULL(result);
457+
EXPECT_NS_EQUAL(result, mainFrameSecretString);
458+
459+
pendingCallbackWasCalled = true;
460+
}];
461+
TestWebKitAPI::Util::run(&pendingCallbackWasCalled);
462+
463+
// Test main frame evaluation failure.
464+
pendingCallbackWasCalled = false;
465+
[sharedInspectorExtension evaluateScript:@"[].x.x" frameURL:nil contextSecurityOrigin:nil useContentScriptContext:false completionHandler:^(NSError *error, NSDictionary *result) {
466+
EXPECT_NULL(result);
467+
EXPECT_NOT_NULL(error);
468+
469+
pendingCallbackWasCalled = true;
470+
}];
471+
TestWebKitAPI::Util::run(&pendingCallbackWasCalled);
472+
473+
// Test loose frameURL evaluation.
474+
auto *testPageInnerFrameFileURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@WKInspectorExtensionEvaluateScriptOnPageInnerFrame.html", [[testPageFileURL URLByDeletingLastPathComponent] absoluteString]]];
475+
476+
pendingCallbackWasCalled = false;
477+
[sharedInspectorExtension evaluateScript:scriptSource frameURL:testPageInnerFrameFileURL contextSecurityOrigin:nil useContentScriptContext:false completionHandler:^(NSError *error, NSDictionary *result) {
478+
EXPECT_NULL(error);
479+
EXPECT_NOT_NULL(result);
480+
EXPECT_NS_EQUAL(result, innerFrameSecretString);
481+
482+
pendingCallbackWasCalled = true;
483+
}];
484+
TestWebKitAPI::Util::run(&pendingCallbackWasCalled);
485+
486+
// Test strict frameURL evaluation.
487+
auto *testPageInnerFrameStrictFileURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@?query=param#fragment", [testPageInnerFrameFileURL absoluteString]]];
488+
489+
pendingCallbackWasCalled = false;
490+
[sharedInspectorExtension evaluateScript:scriptSource frameURL:testPageInnerFrameStrictFileURL contextSecurityOrigin:nil useContentScriptContext:false completionHandler:^(NSError *error, NSDictionary *result) {
491+
EXPECT_NULL(error);
492+
EXPECT_NOT_NULL(result);
493+
EXPECT_NS_EQUAL(result, innerFrameSecretString);
494+
495+
pendingCallbackWasCalled = true;
496+
}];
497+
TestWebKitAPI::Util::run(&pendingCallbackWasCalled);
498+
499+
// Unregister the test extension.
500+
pendingCallbackWasCalled = false;
501+
[[webView _inspector] unregisterExtension:sharedInspectorExtension.get() completionHandler:^(NSError * error) {
502+
EXPECT_NULL(error);
503+
504+
pendingCallbackWasCalled = true;
505+
}];
506+
TestWebKitAPI::Util::run(&pendingCallbackWasCalled);
507+
}
508+
385509
#endif // ENABLE(INSPECTOR_EXTENSIONS)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<html>
2+
<head>Test page to be inspected</head>
3+
<body>
4+
<p>Test page to be inspected.</p>
5+
<p id="secret">42-mainFrame</p>
6+
<iframe src="./WKInspectorExtensionEvaluateScriptOnPageInnerFrame.html?query=param#fragment"></iframe>
7+
</body>
8+
</html>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<html>
2+
<head>Test inner frame to be inspected</head>
3+
<body>
4+
<p>Test inner frame to be inspected.</p>
5+
<p id="secret">42-innerFrame</p>
6+
</body>
7+
</html>

0 commit comments

Comments
 (0)