forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PEPC] Close PEPC prompt on tab switch
As per the DD the PEPC prompt should be closed when tab switching. This CL introduces a new TabSwitchingBehavior that closes the request as "Ignored" but also calls the "Cancelled" callback. This is needed to allow PEPC requests to notify the renderer of the prompt being closed in order to raise the "dismiss" event. Additionally during this CL a flaw was identified in PermissionElementBrowserTest which allowed all tests to falsely pass. |waitForResolveEvent| would immediately return true which made it appear that all conditions are met. This CL fixes that by using console logs to determine which events have been raised so far, and checking that they are the expected ones. Fixed: 339792166 Change-Id: I3671f0b425c54ed889fa24484ed0e09d1ecb6884 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5526465 Commit-Queue: Andy Paicu <andypaicu@chromium.org> Reviewed-by: Thomas Nguyen <tungnh@chromium.org> Cr-Commit-Position: refs/heads/main@{#1300313}
- Loading branch information
Showing
4 changed files
with
114 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,30 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<script> | ||
function waitForDismissEvent(id) { | ||
(async () => { | ||
await new Promise(resolve => { | ||
document.getElementById(id).ondismiss = function (event) { | ||
resolve(); | ||
}; | ||
}); | ||
})(); | ||
return true; | ||
} | ||
|
||
function waitForResolveEvent(id) { | ||
(async () => { | ||
await new Promise(resolve => { | ||
document.getElementById(id).onresolve = function (event) { | ||
resolve(); | ||
}; | ||
}); | ||
})(); | ||
return true; | ||
} | ||
|
||
function clickById(element_id) { | ||
click(document.getElementById(element_id)); | ||
} | ||
|
||
function click(element) { | ||
element.click(); | ||
} | ||
</script> | ||
<body> | ||
<permission id="geolocation" type="geolocation"> | ||
<permission id="microphone" type="microphone"> | ||
<permission id="camera" type="camera"> | ||
<permission id="invalid" type="invalid microphone"> | ||
<permission id="camera-microphone" type="camera microphone"> | ||
<script> | ||
document.querySelectorAll('permission').forEach(permissionElement => { | ||
// Console logs are used to inform the browser test which events | ||
// have been seen. | ||
permissionElement.addEventListener('resolve', (event) => { | ||
console.log(event.target.id + '-resolve'); | ||
}); | ||
permissionElement.addEventListener('dismiss', (event) => { | ||
console.log(event.target.id + '-dismiss'); | ||
}); | ||
}); | ||
|
||
function clickById(element_id) { | ||
click(document.getElementById(element_id)); | ||
} | ||
|
||
function click(element) { | ||
element.click(); | ||
} | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters