-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
refactor(context): Future-proofed context.html and debug.html for modularity #2019
refactor(context): Future-proofed context.html and debug.html for modularity #2019
Conversation
} | ||
}; | ||
|
||
// Configure our Karma | ||
%CLIENT_CONFIG% |
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.
One thing I'm uncertain of is if we should call window.__karma__.setupContext(window)
here or not. We would need to overwrite window.__karma__
to be a noop in context-debug.js
but I can't think of a case when we would need it.
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.
Crazy idea, couldn't we inject the %CLIENT_CONFIG%
into the context.js
files, and call .setupContext
in there. That way we could add it much easier at a later point in time to context-debug.js
if we need to.
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.
We could inject CLIENT_CONFIG
inside of the .js
files but would need to do it in a linter friendly way. For example:
// In client.js
window.__karma__.config = {PLACEHOLDER: 'FOR_CLIENT_CONFIG'}
// In middleware
data = data.replace('{PLACEHOLDER: \'FOR_CLIENT_CONFIG\'}', configJson);
imo, the current setup is good since it's minimal tax to maintain (e.g. no chance of escaping errors) and there are no major benefits to the other setup
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.
With respect to running setupContext
in context.js
, we can't do that since we would need to override it in debug.html
before it's called. Otherwise, we would have overridden window.alert
, window.onbeforeunload
, and more in debug.html
which I believe we don't want
1d8c1b3
to
378d61e
Compare
// serve karma.js | ||
if (requestUrl === '/karma.js') { | ||
// serve karma.js, context.js, and context-debug.js | ||
var jsFiles = ['/karma.js', '/context.js', '/context-debug.js'] |
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.
Let's drop the /
in the filenames and add it dynamically on the matches to avoid typo issues in the future.
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'm confused. Do you mean requestUrl.match(/(karma|context|context-debug)\/.js
or to always do replacement (effectively an if true
)?
Can you add the notice about the breaking change in the commit please. See http://karma-runner.github.io/0.13/dev/git-commit-msg.html for how to do that |
Technically, it's not a breaking change since the |
dc7725d
to
ad487a7
Compare
I took care of the linter errors. I'm still confused about so I left it alone I snuck in a rename from |
Alright retriggered CI to make sure those are green, after that I'm going to merge it. Sorry for the delay |
I hit "Update branch" but it looks like those are creating merge commits instead of doing a rebase. I'm going to rebase in a bit. |
2ec875e
to
d8e65ab
Compare
Alright, pushed a rebased flavor |
Ugh, I lost the commit body in my rebase x_x |
…ularity BREAKING CHANGE: Our `context.html` and `debug.html` structures have changed to lean on `context.js` and `debug.js`. This is in preparation for deeper `context.js` changes in karma-runner#1984. As a result, all `customContextFile` and `customDebugFile` options much update their format to match this new format.
d8e65ab
to
43f6a1a
Compare
Aaaand restored:
|
Thanks, going to close this in favor of the other PR, so I don't get any issues with merge things as #2020 contains these commits as well |
There should be no issues as long as they are landed in order but works for me =P |
In #1984, we will update
context.html
anddebug.html
to centralize the majority Karma's and their logic into scripts. In the next Karma release, we are planning on addingcustomContextFile
andcustomDebugFile
. Since any existing custom context files would be incompatible with this centralization, it would be a breaking change.To avoid the breaking change/another major release, we want to future-proof
context.html
anddebug.html
. In this PR:window.opener
/window.parent
logic forcontext.html
intocontext.js
window.__karma__
definitions indebug.html
tocontext-debug.html
debug.html's JS
to be override onwindow.__karma__
rather than define itwindow.__karma__.stringify
to be defined without needing to compile a newcontext-debug.js
Screenshot of debug.html working: