-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[JENKINS-70895] skip isSecureContext
check in automated tests
#7784
[JENKINS-70895] skip isSecureContext
check in automated tests
#7784
Conversation
https://issues.jenkins.io/browse/JENKINS-70895 reports that `isSecureContext` is not recognized by HTMLUnit in its JavaScript handling. That breaks tests for some plugins that use HTMLUnit to test configuration round trips. jenkinsci#7665 introduced this change to notify users running over HTTP connections (insecure) that the copy button does not work over insecure connections. https://issues.jenkins.io/browse/JENKINS-21052 was the original motivation for that informational message to the user. James Nord tested this change in the automated test that was failing with Jenkins 2.397 and confirmed that the test passes with this change. I tested interactively over HTTP and confirmed that the copy button on the inbound agent page still reports that copy is not supported over an insecure session. I tested interactively over HTTPS and confirmed that the copy button on the inbound agent page still correctly copies the expected content. I spent several unsuccessful hours trying to create an automated test to show the failure. I think we should include this fix without an automated test because the automated tests in the plugin that James maintains will detect the issue.
validated the change with one of the failing plugins and |
// HTMLUnit 2.70.0 does not recognize isSecureContext | ||
// https://issues.jenkins.io/browse/JENKINS-70895 | ||
if (!window.isRunAsTest && isSecureContext) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't
// HTMLUnit 2.70.0 does not recognize isSecureContext | |
// https://issues.jenkins.io/browse/JENKINS-70895 | |
if (!window.isRunAsTest && isSecureContext) { | |
if (!window.isSecureContext) { |
be the simpler change (found in @jtnord's Jira comment)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see documentation on MDN for the global isSecureContext
. In the MDN documentation for window
, the window.isSecureContext
heading links to the documentation of the global property. I assumed that means the MDN recommends use of the global rather than using window.isSecureContext
.
There is not a window.isSecureContext
page on MDN (404 from https://developer.mozilla.org/en-US/docs/Web/API/Window/isSecureContext ), though there was at one point as indicated by a link from a stackoverflow article.
I also believe that I read a recommendation on some location that the global isSecureContext
was preferred. However, I can't find that reference now.
I also prefer the added check of window.isRunAsTest
because it makes it clear that this workaround can be removed when we update to an HTMLUnit version that recognizes the global isSecureContext
. See the response from the maintainer of HTMLUnit in:
If changing the implementation to the window.secureContext
instead of !window.isRunAsTest && isSecureConext
will allow this to be merged, then I am happy to change it to that form.
The W3C Candidate Recommendation Draft, 18 September 2021 spec for secure context says in section 2.2.2:
An application can determine whether it’s executing in a secure context by checking the isSecureContext boolean defined on WindowOrWorkerGlobalScope.
Since the spec says that the boolean is defined on window or worker global scope, I believe we can use either of them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine for me either way, just seemed simpler.
This PR is now ready for merge. We will merge it after approximately 24 hours if there is no negative feedback. |
JENKINS-70895 skip
isSecureContext
check in automated testsJENKINS-70895 reports that
isSecureContext
is not recognized by HTMLUnit in its JavaScript handling. That breaks tests for some plugins that use HTMLUnit to test configuration round trips.#7665 introduced this change to notify users running over HTTP connections (insecure) that the copy button does not work over insecure connections.
JENKINS-21052 was the original motivation for that informational message to the user.
Testing done
I spent several unsuccessful hours trying to create an automated test to show the failure. I think we should include this fix without an automated test because the automated tests in the plugin that James maintains will detect the issue.
Proposed changelog entries
Proposed upgrade guidelines
N/A
Submitter checklist
@Restricted
or have@since TODO
Javadocs, as appropriate.@Deprecated(since = "TODO")
or@Deprecated(forRemoval = true, since = "TODO")
, if applicable.eval
to ease future introduction of Content Security Policy (CSP) directives (see documentation).Desired reviewers
@jtnord
Maintainer checklist
Before the changes are marked as
ready-for-merge
:upgrade-guide-needed
label is set and there is a Proposed upgrade guidelines section in the pull request title (see example).lts-candidate
to be considered (see query).