Closed Bug 1309970 Opened 8 years ago Closed 8 years ago

Add a shim to alias .contains to .includes on the array returned from DataTransfer.types in chrome code only

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla52
Tracking Status
firefox52 --- fixed

People

(Reporter: bzbarsky, Assigned: bzbarsky)

References

Details

Attachments

(2 files)

Blocks: 1298243
Note that I considered hardcoding the interface/member name pair in codegen, but this seems slightly more flexible...
Comment on attachment 8800814 [details] [diff] [review]
Add a way to return frozen arrays to chrome callers with a .contains defined on them, returning the same value as .includes

Review of attachment 8800814 [details] [diff] [review]:
-----------------------------------------------------------------

LGTM, and yeah, I like this method better than hardcoding also.
Attachment #8800814 - Flags: review?(kyle) → review+
Pushed by bzbarsky@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/7e0d01e910bf
Add a way to return frozen arrays to chrome callers with a .contains defined on them, returning the same value as .includes.  r=qdot
https://hg.mozilla.org/mozilla-central/rev/7e0d01e910bf
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla52
This does not appear to be fixed in 52.4.1esr on win 7 64 bit, as best as naive me can tell.

In particular, the Scrapbook add-on seems to fail according to this review:

https://addons.mozilla.org/en-US/firefox/addon/scrapbook/reviews/840502/

Looking at the code he references, here is a snippet:

	onDragOver: function(event) {
		var dataTransfer = event.dataTransfer;
		if (dataTransfer.types.contains("moz/rdfitem") || 
		    dataTransfer.types.contains("sb/tradeitem") || 
		    dataTransfer.types.contains("text/x-moz-url") || 
		    dataTransfer.types.contains("text/html") || 
		    dataTransfer.types.contains("application/x-moz-tabbrowser-tab")) {
			event.preventDefault();
			if (event.ctrlKey || event.shiftKey)
				dataTransfer.dropEffect = "copy";
			else if (event.altKey)
				dataTransfer.dropEffect = "link";
		}
	},

As I read the comments here and in Bug 1298243, the above should work, but apparently it does not.

Unfortunately, I really know next to nothing about these APIs, so could someone please check this?

Attaching full module this is in, "tree.js".
Tree.js file from Scrapbook add-on.  It seems that this should work based on the current bug being fixed, but it fails as mentioned in my last comment.
> In particular, the Scrapbook add-on seems to fail according to this review:

The review says that the types exposed via dataTransfer.types changed in that situation and the addon needs to deal.

The review does mention the contains/includes bit as something the addon author might want to do, but it shouldn't be necessary as far as I can tell; the real failure is with how the types are gotten.

If you have steps to reproduce that show dataTransfer.types.contains being undefined, please file a new bug with steps to reproduce the problem and cc me.
Note that I filed bug 1412463 to remove this shim in a future (post-57) Firefox release, since I expect webextensions don't depend on it.
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: