From 2c0b407f04e850b45c912917026e4945ec0dc2f5 Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Mon, 12 Feb 2018 19:40:38 +0100 Subject: JS - location.hash - no escape single quote --- netwerk/test/unit/test_standardurl.js | 11 +++++++++++ xpcom/io/nsEscape.cpp | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/netwerk/test/unit/test_standardurl.js b/netwerk/test/unit/test_standardurl.js index c4d44f41ff..476c34b70b 100644 --- a/netwerk/test/unit/test_standardurl.js +++ b/netwerk/test/unit/test_standardurl.js @@ -251,6 +251,17 @@ add_test(function test_escapeBrackets() run_next_test(); }); +add_test(function test_escapeQuote() +{ + var url = stringToURL("http://example.com/#'"); + do_check_eq(url.spec, "http://example.com/#'"); + do_check_eq(url.ref, "'"); + url.ref = "test'test"; + do_check_eq(url.spec, "http://example.com/#test'test"); + do_check_eq(url.ref, "test'test"); + run_next_test(); +}); + add_test(function test_apostropheEncoding() { // For now, single quote is escaped everywhere _except_ the path. diff --git a/xpcom/io/nsEscape.cpp b/xpcom/io/nsEscape.cpp index f16edc4ce7..117e20d601 100644 --- a/xpcom/io/nsEscape.cpp +++ b/xpcom/io/nsEscape.cpp @@ -346,7 +346,7 @@ static const uint32_t EscapeChars[256] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x - 0,1023, 0, 512,1023, 0,1023, 112,1023,1023,1023,1023,1023,1023, 953, 784, // 2x !"#$%&'()*+,-./ + 0,1023, 0, 512,1023, 0,1023, 624,1023,1023,1023,1023,1023,1023, 953, 784, // 2x !"#$%&'()*+,-./ 1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1008,1008, 0,1008, 0, 768, // 3x 0123456789:;<=>? 1008,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023, // 4x @ABCDEFGHIJKLMNO 1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1008, 896,1008, 896,1023, // 5x PQRSTUVWXYZ[\]^_ -- cgit v1.2.3 From f8b9aba8214b9c1f6ccd5852879d6a1cbb16a304 Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Sun, 15 Apr 2018 06:51:24 +0200 Subject: moebius#106: SVG - CanvasImageSource - allow using an SVGImageElement as a CanvasImageSource --- dom/canvas/CanvasRenderingContext2D.cpp | 24 ++++++++++++----- dom/canvas/CanvasRenderingContext2D.h | 4 +-- dom/webidl/CanvasRenderingContext2D.webidl | 3 +++ testing/web-platform/meta/MANIFEST.json | 12 +++++++++ .../drawimage_html_image_1.html | 30 ---------------------- .../drawimage_html_image_1_ref.html | 19 -------------- .../drawimage_svg_image_1.html | 30 ++++++++++++++++++++++ .../drawimage_svg_image_1_ref.html | 19 ++++++++++++++ 8 files changed, 84 insertions(+), 57 deletions(-) delete mode 100644 testing/web-platform/tests/2dcontext/drawing-images-to-the-canvas/drawimage_html_image_1.html delete mode 100644 testing/web-platform/tests/2dcontext/drawing-images-to-the-canvas/drawimage_html_image_1_ref.html create mode 100644 testing/web-platform/tests/2dcontext/drawing-images-to-the-canvas/drawimage_svg_image_1.html create mode 100644 testing/web-platform/tests/2dcontext/drawing-images-to-the-canvas/drawimage_svg_image_1_ref.html diff --git a/dom/canvas/CanvasRenderingContext2D.cpp b/dom/canvas/CanvasRenderingContext2D.cpp index 15df2b3377..a38c382938 100644 --- a/dom/canvas/CanvasRenderingContext2D.cpp +++ b/dom/canvas/CanvasRenderingContext2D.cpp @@ -105,6 +105,7 @@ #include "mozilla/dom/CanvasPath.h" #include "mozilla/dom/HTMLImageElement.h" #include "mozilla/dom/HTMLVideoElement.h" +#include "mozilla/dom/SVGImageElement.h" #include "mozilla/dom/SVGMatrix.h" #include "mozilla/dom/TextMetrics.h" #include "mozilla/dom/SVGMatrix.h" @@ -2477,10 +2478,10 @@ CanvasRenderingContext2D::CreatePattern(const CanvasImageSource& aSource, return nullptr; } - Element* htmlElement; + Element* element; if (aSource.IsHTMLCanvasElement()) { HTMLCanvasElement* canvas = &aSource.GetAsHTMLCanvasElement(); - htmlElement = canvas; + element = canvas; nsIntSize size = canvas->GetSize(); if (size.width == 0 || size.height == 0) { @@ -2505,7 +2506,7 @@ CanvasRenderingContext2D::CreatePattern(const CanvasImageSource& aSource, } RefPtr pat = - new CanvasPattern(this, srcSurf, repeatMode, htmlElement->NodePrincipal(), canvas->IsWriteOnly(), false); + new CanvasPattern(this, srcSurf, repeatMode, element->NodePrincipal(), canvas->IsWriteOnly(), false); return pat.forget(); } @@ -2516,11 +2517,19 @@ CanvasRenderingContext2D::CreatePattern(const CanvasImageSource& aSource, return nullptr; } - htmlElement = img; + element = img; + } else if (aSource.IsSVGImageElement()) { + SVGImageElement* img = &aSource.GetAsSVGImageElement(); + if (img->IntrinsicState().HasState(NS_EVENT_STATE_BROKEN)) { + aError.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); + return nullptr; + } + + element = img; } else if (aSource.IsHTMLVideoElement()) { auto& video = aSource.GetAsHTMLVideoElement(); video.MarkAsContentSource(mozilla::dom::HTMLVideoElement::CallerAPI::CREATE_PATTERN); - htmlElement = &video; + element = &video; } else { // Special case for ImageBitmap ImageBitmap& imgBitmap = aSource.GetAsImageBitmap(); @@ -2559,7 +2568,7 @@ CanvasRenderingContext2D::CreatePattern(const CanvasImageSource& aSource, // The canvas spec says that createPattern should use the first frame // of animated images nsLayoutUtils::SurfaceFromElementResult res = - nsLayoutUtils::SurfaceFromElement(htmlElement, + nsLayoutUtils::SurfaceFromElement(element, nsLayoutUtils::SFE_WANT_FIRST_FRAME, mTarget); if (!res.GetSourceSurface()) { @@ -4949,6 +4958,9 @@ CanvasRenderingContext2D::DrawImage(const CanvasImageSource& aImage, if (aImage.IsHTMLImageElement()) { HTMLImageElement* img = &aImage.GetAsHTMLImageElement(); element = img; + } else if (aImage.IsSVGImageElement()) { + SVGImageElement* img = &aImage.GetAsSVGImageElement(); + element = img; } else { HTMLVideoElement* video = &aImage.GetAsHTMLVideoElement(); video->MarkAsContentSource(mozilla::dom::HTMLVideoElement::CallerAPI::DRAW_IMAGE); diff --git a/dom/canvas/CanvasRenderingContext2D.h b/dom/canvas/CanvasRenderingContext2D.h index c3ee3bdcbc..d5dff8f3b0 100644 --- a/dom/canvas/CanvasRenderingContext2D.h +++ b/dom/canvas/CanvasRenderingContext2D.h @@ -38,8 +38,8 @@ class SourceSurface; } // namespace gl namespace dom { -class HTMLImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap; -typedef HTMLImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap CanvasImageSource; +class HTMLImageElementOrSVGImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap; +typedef HTMLImageElementOrSVGImageElementOrHTMLCanvasElementOrHTMLVideoElementOrImageBitmap CanvasImageSource; class ImageData; class StringOrCanvasGradientOrCanvasPattern; class OwningStringOrCanvasGradientOrCanvasPattern; diff --git a/dom/webidl/CanvasRenderingContext2D.webidl b/dom/webidl/CanvasRenderingContext2D.webidl index 38a30f9e39..1c55642152 100644 --- a/dom/webidl/CanvasRenderingContext2D.webidl +++ b/dom/webidl/CanvasRenderingContext2D.webidl @@ -27,6 +27,9 @@ dictionary HitRegionOptions { }; typedef (HTMLImageElement or + SVGImageElement) HTMLOrSVGImageElement; + +typedef (HTMLOrSVGImageElement or HTMLCanvasElement or HTMLVideoElement or ImageBitmap) CanvasImageSource; diff --git a/testing/web-platform/meta/MANIFEST.json b/testing/web-platform/meta/MANIFEST.json index 65626d6b8c..ca574833b5 100644 --- a/testing/web-platform/meta/MANIFEST.json +++ b/testing/web-platform/meta/MANIFEST.json @@ -39138,6 +39138,18 @@ "url": "/2dcontext/drawing-images-to-the-canvas/drawimage_html_image_9.html" } ], + "2dcontext/drawing-images-to-the-canvas/drawimage_svg_image_1.html": [ + { + "path": "2dcontext/drawing-images-to-the-canvas/drawimage_svg_image_1.html", + "references": [ + [ + "/2dcontext/drawing-images-to-the-canvas/drawimage_svg_image_1_ref.html", + "==" + ] + ], + "url": "/2dcontext/drawing-images-to-the-canvas/drawimage_svg_image_1.html" + } + ], "2dcontext/line-styles/canvas_linestyles_linecap_001.htm": [ { "path": "2dcontext/line-styles/canvas_linestyles_linecap_001.htm", diff --git a/testing/web-platform/tests/2dcontext/drawing-images-to-the-canvas/drawimage_html_image_1.html b/testing/web-platform/tests/2dcontext/drawing-images-to-the-canvas/drawimage_html_image_1.html deleted file mode 100644 index b9de85a977..0000000000 --- a/testing/web-platform/tests/2dcontext/drawing-images-to-the-canvas/drawimage_html_image_1.html +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - diff --git a/testing/web-platform/tests/2dcontext/drawing-images-to-the-canvas/drawimage_html_image_1_ref.html b/testing/web-platform/tests/2dcontext/drawing-images-to-the-canvas/drawimage_html_image_1_ref.html deleted file mode 100644 index 60545df17f..0000000000 --- a/testing/web-platform/tests/2dcontext/drawing-images-to-the-canvas/drawimage_html_image_1_ref.html +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - -
- - diff --git a/testing/web-platform/tests/2dcontext/drawing-images-to-the-canvas/drawimage_svg_image_1.html b/testing/web-platform/tests/2dcontext/drawing-images-to-the-canvas/drawimage_svg_image_1.html new file mode 100644 index 0000000000..74a00e037d --- /dev/null +++ b/testing/web-platform/tests/2dcontext/drawing-images-to-the-canvas/drawimage_svg_image_1.html @@ -0,0 +1,30 @@ + + + + + + diff --git a/testing/web-platform/tests/2dcontext/drawing-images-to-the-canvas/drawimage_svg_image_1_ref.html b/testing/web-platform/tests/2dcontext/drawing-images-to-the-canvas/drawimage_svg_image_1_ref.html new file mode 100644 index 0000000000..60545df17f --- /dev/null +++ b/testing/web-platform/tests/2dcontext/drawing-images-to-the-canvas/drawimage_svg_image_1_ref.html @@ -0,0 +1,19 @@ + + + + + + + +
+ + -- cgit v1.2.3 From 05bb04a6514d2e6557dc0697c34a56cfd2c399a4 Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Sun, 15 Apr 2018 06:55:40 +0200 Subject: moebius#190: HTML - table - editor (contenteditable) - post process node array to remove all descendants of replacement node https://github.com/MoonchildProductions/moebius/issues/190 --- editor/libeditor/HTMLEditorDataTransfer.cpp | 31 +++++++------- editor/libeditor/tests/mochitest.ini | 3 ++ editor/libeditor/tests/test_bug1306532.html | 64 +++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+), 16 deletions(-) create mode 100644 editor/libeditor/tests/test_bug1306532.html diff --git a/editor/libeditor/HTMLEditorDataTransfer.cpp b/editor/libeditor/HTMLEditorDataTransfer.cpp index b9cd8adb95..ed350c0dd3 100644 --- a/editor/libeditor/HTMLEditorDataTransfer.cpp +++ b/editor/libeditor/HTMLEditorDataTransfer.cpp @@ -2382,27 +2382,26 @@ HTMLEditor::ReplaceOrphanedStructure( } // If we found substructure, paste it instead of its descendants. - // Only replace with the substructure if all the nodes in the list are - // descendants. - bool shouldReplaceNodes = true; - for (uint32_t i = 0; i < aNodeArray.Length(); i++) { + // Postprocess list to remove any descendants of this node so that we don't + // insert them twice. + uint32_t removedCount = 0; + uint32_t originalLength = aNodeArray.Length(); + for (uint32_t i = 0; i < originalLength; i++) { uint32_t idx = aStartOrEnd == StartOrEnd::start ? - i : (aNodeArray.Length() - i - 1); + (i - removedCount) : (originalLength - i - 1); OwningNonNull endpoint = aNodeArray[idx]; - if (!EditorUtils::IsDescendantOf(endpoint, replaceNode)) { - shouldReplaceNodes = false; - break; + if (endpoint == replaceNode || + EditorUtils::IsDescendantOf(endpoint, replaceNode)) { + aNodeArray.RemoveElementAt(idx); + removedCount++; } } - if (shouldReplaceNodes) { - // Now replace the removed nodes with the structural parent - aNodeArray.Clear(); - if (aStartOrEnd == StartOrEnd::end) { - aNodeArray.AppendElement(*replaceNode); - } else { - aNodeArray.InsertElementAt(0, *replaceNode); - } + // Now replace the removed nodes with the structural parent + if (aStartOrEnd == StartOrEnd::end) { + aNodeArray.AppendElement(*replaceNode); + } else { + aNodeArray.InsertElementAt(0, *replaceNode); } } diff --git a/editor/libeditor/tests/mochitest.ini b/editor/libeditor/tests/mochitest.ini index 9aafa0ac2f..4df3f606b6 100644 --- a/editor/libeditor/tests/mochitest.ini +++ b/editor/libeditor/tests/mochitest.ini @@ -217,6 +217,9 @@ skip-if = toolkit == 'android' [test_bug1258085.html] [test_bug1268736.html] [test_bug1270235.html] +[test_bug1306532.html] +subsuite = clipboard +skip-if = toolkit == 'android' [test_bug1310912.html] skip-if = toolkit == 'android' # bug 1315898 [test_bug1314790.html] diff --git a/editor/libeditor/tests/test_bug1306532.html b/editor/libeditor/tests/test_bug1306532.html new file mode 100644 index 0000000000..1d7b3e7afd --- /dev/null +++ b/editor/libeditor/tests/test_bug1306532.html @@ -0,0 +1,64 @@ + + +Test for bug 1306532 + + + + + + + +Mozilla Bug 1306532 +

+ +
+
+ +
+ + + + + + + + + +
MonthSavings
January$100
+
+ + + + + -- cgit v1.2.3 From ae14556114dcae29f679db7c15f0bc9b707bb89a Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Sun, 15 Apr 2018 07:29:18 +0200 Subject: moebius#130: URL parser - fix: don't allow empty host name https://github.com/MoonchildProductions/moebius/issues/130 --- docshell/test/unit/test_nsDefaultURIFixup_info.js | 6 ----- dom/html/test/test_bug558788-1.html | 5 ++-- dom/url/tests/test_url.html | 12 +++++++++ extensions/cookie/test/unit/test_bug526789.js | 12 --------- netwerk/base/nsStandardURL.cpp | 31 +++++++++++++++------- netwerk/test/unit/test_URIs.js | 24 ----------------- netwerk/test/unit/test_standardurl.js | 8 ++++++ .../tests/xpcshell/test_oauth_grant_client.js | 2 +- .../tests/xpcshell/test_profile_client.js | 2 +- .../meta/XMLHttpRequest/open-url-bogus.htm.ini | 11 -------- .../web-platform/meta/url/url-constructor.html.ini | 3 --- .../passwordmgr/test/unit/test_logins_search.js | 1 - toolkit/components/places/UnifiedComplete.js | 2 +- toolkit/components/places/nsNavHistory.cpp | 4 +++ 14 files changed, 51 insertions(+), 72 deletions(-) delete mode 100644 testing/web-platform/meta/XMLHttpRequest/open-url-bogus.htm.ini diff --git a/docshell/test/unit/test_nsDefaultURIFixup_info.js b/docshell/test/unit/test_nsDefaultURIFixup_info.js index 9e33ea484f..c606ac32ef 100644 --- a/docshell/test/unit/test_nsDefaultURIFixup_info.js +++ b/docshell/test/unit/test_nsDefaultURIFixup_info.js @@ -426,8 +426,6 @@ var testcases = [ { protocolChange: true, }, { input: "?'.com", - fixedURI: "http:///?%27.com", - alternateURI: "http://www..com/?%27.com", keywordLookup: true, protocolChange: true, }, { @@ -436,14 +434,10 @@ var testcases = [ { protocolChange: true }, { input: "?mozilla", - fixedURI: "http:///?mozilla", - alternateURI: "http://www..com/?mozilla", keywordLookup: true, protocolChange: true, }, { input: "??mozilla", - fixedURI: "http:///??mozilla", - alternateURI: "http://www..com/??mozilla", keywordLookup: true, protocolChange: true, }, { diff --git a/dom/html/test/test_bug558788-1.html b/dom/html/test/test_bug558788-1.html index 94b7a5f00e..4db61ed738 100644 --- a/dom/html/test/test_bug558788-1.html +++ b/dom/html/test/test_bug558788-1.html @@ -154,13 +154,14 @@ function checkInputURL() sendString("ttp://mozilla.org"); checkValidApplies(element); - for (var i=0; i<13; ++i) { + for (var i=0; i<10; ++i) { synthesizeKey("VK_BACK_SPACE", {}); checkValidApplies(element); } synthesizeKey("VK_BACK_SPACE", {}); - for (var i=0; i<4; ++i) { + // "http://" is now invalid + for (var i=0; i<7; ++i) { checkInvalidApplies(element); synthesizeKey("VK_BACK_SPACE", {}); } diff --git a/dom/url/tests/test_url.html b/dom/url/tests/test_url.html index d07a752bb4..73e75667d8 100644 --- a/dom/url/tests/test_url.html +++ b/dom/url/tests/test_url.html @@ -398,6 +398,18 @@ is(url.href, "scheme://tmp\\test"); + +