You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Remove all assert_object_equals instances from the suite. #2033
So I really really wish this function didn't exist; I think it's almost never a good idea to use it. This change is also backward-incompatible although hopefully no one is abusing the current behaviour.
I would honestly prefer to eradicate all uses of this function. What's the use case you have in mind?
The motiviation for this change is its use with the Service Worker Cache Storage tests, which put a Request/Response pair in and validate that the properties are the same when retrieved.
Blink was monkey-patching assert_object_equals() with something that worked but was a very different assertion and buggy in a different way. I recently eliminated the monkey-patch (well, at least one, just found another) and wanted to just use the built-in, but properly fixed.
But in the abstract, the use case is to take two DOM objects and assert that "properties" are equivalent. We could introduce a new assertion for that, or write a type specific helper just for the SW/CS tests.
IndexedDB/ - comparing keys, values, arrays of strings (i.e. plain JS objects)
service-workers/cache-storage/ - as noted, comparing Requests/Responses (DOM objects); could use dedicated comparison functions
webmessaging/ - comparing cloned objects, also has a wrapper handles Date and RegExp instances
And then a couple of one-offs:
ext-xhtml-pubid/the-xhtml-syntax/parsing-xhtml-documents/xhtml-pubid-1.html - just comparing against null, but the test should really be assert_throws; the whole test looks poorly written.
html/semantics/embedded-content/media-elements/track/track-element/cors/support/common.js - test expectations are described in an object (event and array of requests); could be replaced by a dedicated comparison loop
So it's really just the IndexedDB and webmessaging code that's wanting a really generic object comparison function. We could have the function assert that the prototypes are Object.prototype or something.
But... this is really a "how do you want to evolve testharness?" question, so I need your thoughts here.
Sorry, yeah, the URL I pasted in before isn’t for the file I actually found it in locally. The one I found it in locally is service-workers/service-worker/resources/testharness-helpers.js but I see now that’s an old file laying around in my working directory, and not actually tracked by git.
We still have:
ext-xhtml-pubid/the-xhtml-syntax/parsing-xhtml-documents/xhtml-pubid-1.html
html/semantics/embedded-content/media-elements/track/track-element/cors/support/common.js
workers/interfaces/DedicatedWorkerGlobalScope/postMessage/structured-clone-message.html
@jgraham: Is assert_object_equals still "broken for DOM objects and undesirable in general?" If so, there's quite a bit more cleanup to do. As of 2017-03-26, assert_object_equals appears in:
Reviewing usage, I note the following patterns in descending order of occurrence:
shorthand for a bunch of property assertions; no need for deep comparison, and even asserting that no extra properties exist is beyond the scope of the test. e.g.
recursive array comparison, where each element is either an array or can be compared with assert_equals()
true deep-compare cases, e.g. validating postMessage()'s event.data or similar arbitrary payloads
broken usage, e.g. in workers/Worker-constructor-proto.any.js
Given the prevalence of the first two, I'd suggest adding a new simpler function to testharness.js, e.g. assert_property_values() (better name pls) which handles the most common bulk property comparison cases as a convenience. I think this accounts for 95%+ of current usage, and we can convert those over. We can then rename assert_object_equals() to something less attractive.
Activity
inexorabletash commentedon Aug 3, 2015
Still waiting on reviews for the two PRs linked above. Anyone? @jgraham ?
Replaced a simple assert_object_equals case.
sideshowbarker commentedon Aug 17, 2015
@inexorabletash you wanna take care of the
assert_object_equalsinstance in https://github.com/w3c/web-platform-tests/blob/master/service-workers/service-workers/resources/test-helpers.js ?Replaced some simple assert_object_equals cases.
inexorabletash commentedon Aug 17, 2015
@sideshowbarker Hrm, I'm not seeing one.
https://github.com/w3c/web-platform-tests/search?utf8=%E2%9C%93&q=assert_object_equals
sideshowbarker commentedon Aug 17, 2015
Sorry, yeah, the URL I pasted in before isn’t for the file I actually found it in locally. The one I found it in locally is
service-workers/service-worker/resources/testharness-helpers.jsbut I see now that’s an old file laying around in my working directory, and not actually tracked by git.So never mind about that one :-)
Replaced some simple assert_object_equals cases.
plehegar commentedon Oct 1, 2015
We still have:
ext-xhtml-pubid/the-xhtml-syntax/parsing-xhtml-documents/xhtml-pubid-1.html
html/semantics/embedded-content/media-elements/track/track-element/cors/support/common.js
workers/interfaces/DedicatedWorkerGlobalScope/postMessage/structured-clone-message.html
bobholt commentedon May 26, 2017
@jgraham: Is
assert_object_equalsstill "broken for DOM objects and undesirable in general?" If so, there's quite a bit more cleanup to do. As of 2017-03-26,assert_object_equalsappears in:/encrypted-media/Google/migrated_to_root_disabled/encrypted-media-keystatuses.html/ext-xhtml-pubid/the-xhtml-syntax/parsing-xhtml-documents/xhtml-pubid-1.html/html/semantics/embedded-content/media-elements/track/track-element/cors/support/common.js/service-workers/service-worker/fetch-request-fallback.https.html/service-workers/service-worker/navigation-redirect.https.html/service-workers/service-worker/resources/override_assert_object_equals.js/service-workers/service-worker/resources/testharness-helpers.js/streams/byte-length-queuing-strategy.js/streams/count-queuing-strategy.js/streams/readable-streams/bad-underlying-sources.js/streams/readable-streams/cancel.js/streams/readable-streams/count-queuing-strategy-integration.js/streams/readable-streams/default-reader.js/streams/readable-streams/general.js/streams/readable-streams/tee.js/streams/resources/rs-test-templates.js/webmessaging/postMessage_objects.sub.htm/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/structured-clone-message.htmlAnd confusingly,
/webmessagingalso implements its own version,assert_object_equals_, in/webmessaging/support/compare.js.At this point, would it be easier to fix what's wrong with
assert_object_equalsintestharness.jsif it's still broken?foolip commentedon Mar 31, 2018
@jgraham, is the discussion in https://critic.hoppipolla.co.uk/showcomment?chain=12186 lost forever?
annevk commentedon Jan 6, 2020
See also #20844.
It seems like
assert_object_equalsis broken in several ways. Should it be linted?inexorabletash commentedon Jan 6, 2020
Reviewing usage, I note the following patterns in descending order of occurrence:
recursive array comparison, where each element is either an array or can be compared with
assert_equals()true deep-compare cases, e.g. validating postMessage()'s event.data or similar arbitrary payloads
broken usage, e.g. in
workers/Worker-constructor-proto.any.jsGiven the prevalence of the first two, I'd suggest adding a new simpler function to testharness.js, e.g.
assert_property_values()(better name pls) which handles the most common bulk property comparison cases as a convenience. I think this accounts for 95%+ of current usage, and we can convert those over. We can then renameassert_object_equals()to something less attractive.11 remaining items
WPT: Fix incorrect use of assert_object_equals
Bug 1617250 [wpt PR 21921] - WPT: Fix incorrect use of assert_object_…
Bug 1617250 [wpt PR 21921] - WPT: Fix incorrect use of assert_object_…
Bug 1617250 [wpt PR 21921] - WPT: Fix incorrect use of assert_object_…
gsnedders commentedon Sep 10, 2020
https://web.archive.org/web/20160402125934/https://critic.hoppipolla.co.uk/showcomment?chain=12186 has it, edited OP.
gsnedders commentedon Sep 10, 2020
@stephenmcgruer pointed out to me we wanted to get rid of assert_object_equals in #25083, which I'd totally forgotten about. https://web-platform-tests.org/writing-tests/testharness-api.html doesn't give it as deprecated, either.
Docs: assert_object_equals is DEPRECATED
Docs: assert_object_equals is DEPRECATED (#25481)
Bug 1664398 [wpt PR 25481] - Docs: assert_object_equals is DEPRECATED…
Bug 1664398 [wpt PR 25481] - Docs: assert_object_equals is DEPRECATED…
Bug 1664398 [wpt PR 25481] - Docs: assert_object_equals is DEPRECATED…
Bug 1664398 [wpt PR 25481] - Docs: assert_object_equals is DEPRECATED…
Bug 1664398 [wpt PR 25481] - Docs: assert_object_equals is DEPRECATED…
Bug 1617250 [wpt PR 21921] - WPT: Fix incorrect use of assert_object_…
Bug 1664398 [wpt PR 25481] - Docs: assert_object_equals is DEPRECATED…