Closed Bug 1045756 Opened 11 years ago Closed 11 years ago

add test to validate interfaces exposed on worker global

Categories

(Core :: DOM: Workers, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla34

People

(Reporter: bkelly, Assigned: bkelly)

Details

Attachments

(1 file, 1 obsolete file)

Currently when we implement a new interface we add it to: dom/tests/mochitest/general/test_interfaces.html In order to verify that only correct interfaces are exposed to the web. We don't currently check what is exposed on the worker global. It would be nice to have a test for workers as well.
Component: DOM → DOM: Workers
Assignee: nobody → bkelly
Status: NEW → ASSIGNED
Attachment #8464146 - Flags: review?(bzbarsky)
Comment on attachment 8464146 [details] [diff] [review] Test DOM interfaces exposed on worker global. >+++ b/dom/workers/test/test_worker_interfaces.js >+ // NB: We haven't bothered to resolve constants like Infinity and NaN on >+ // Xrayed windows (which are seen from the XBL scope). We could support >+ // this if needed with some refactoring. >+ {name: "Infinity", xbl: false}, ... >+ {name: "NaN", xbl: false}, There is no XBL in workers. Just make Infinity and NaN unconditional and remove that comment. >+++ b/dom/workers/test/worker_driver.js Might be nice to have a comment about how this and worker_wrapper allow you to do ok() and is() in worker tests and handle it for you. >+++ b/dom/workers/test/worker_wrapper.js >+ dump("OK: " + !!a + " => " + a + " " + msg + "\n"); ':' after the |a +| bit, like in the message you post? >+ dump("IS: " + (a===b) + " => " + a + " | " + b + " " + msg + "\n"); Similar. That's assuming we want to keep the dump() statements, which seems reasonable. >+var WorkerTest = { Why do we need both the WorkerTest.done() variant and the workerTestDone variant? Seems like a lot of code duplication for no obvious reason. >+ getPrefs: function(prefs, cb) { So this can be a bit of a footgun. Say the worker script being tested does: getPrefs(["a"], function() { /* stuff */ }); getPrefs(["b"], function() { /* other stuff }); Then the "other stuff" will end up with the pref value for "a". Does it make sense to have some sort of sequence id for these requests that we capture in the event listener closure and send back and forth in the messages? Alternately, we could set a global flag in the worker if we have a listener pending and just fail the test if the worker script attempts to add another listener while one is pending. Might be simpler and still catch people screwing up. r=me with those issues addressed
Attachment #8464146 - Flags: review?(bzbarsky) → review+
(In reply to Boris Zbarsky [:bz] (On vacation Aug 5-18) from comment #2) > >+var WorkerTest = { > > Why do we need both the WorkerTest.done() variant and the workerTestDone > variant? Seems like a lot of code duplication for no obvious reason. Oops. WorkerTest was supposed to be deleted. Its actually commented out in the patch. I originally was using WorkerTest, but switched to straight functions to avoid polluting the global.
Removed stale code and fixed other formatting nits. In regard to workerTestGetPrefs(), I chose to echo back the requested prefs array in the response. The worker listener then ignores any messages with the wrong list of prefs. I added this for workerTestGetPermissions() as well. Finally, I added a type parameter to all of the main-thread-to-worker response messages to avoid any cross-talk between the functions. Try build: https://treeherder.mozilla.org/ui/#/jobs?repo=try&revision=38311d0394a5
Attachment #8464146 - Attachment is obsolete: true
Attachment #8465896 - Flags: review+
Yay! Thanks for doing this, Ben!
>+ {name: "Infinity"}, Just "Infinity" would work... Btw, this caught a bug which I'll likely fix in 1017988: Console is exposed in workers!
(In reply to Boris Zbarsky [:bz] (On vacation Aug 5-18) from comment #7) > >+ {name: "Infinity"}, > > Just "Infinity" would work... > > Btw, this caught a bug which I'll likely fix in 1017988: Console is exposed > in workers! That's not a bug; console works find in workers.
(In reply to Boris Zbarsky [:bz] (On vacation Aug 5-18) from comment #7) > >+ {name: "Infinity"}, > > Just "Infinity" would work... Ah, well I already pushed to inbound. Since this still works I'm inclined to leave it and we can clean it up in a later patch. (In reply to :Ms2ger from comment #8) > (In reply to Boris Zbarsky [:bz] (On vacation Aug 5-18) from comment #7) > > Btw, this caught a bug which I'll likely fix in 1017988: Console is exposed > > in workers! > > That's not a bug; console works find in workers. But is console available in workers in the spec or in other browsers?
self.console works in workers. self.Console should not be exposed until we decide to expose it, just like it's not exposed on window and not exposed in other browsers. Console is marked as ChromeOnly for the interface object, but of course workers ignore that right now. The patches in bug 1017988 fix that, fwiw.
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla34
QA Whiteboard: [qa-]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: