internal/export/idna: make Transitional an actual toggle

Previously, it always enabled transitional processing instead of
toggling, despite the fact that it took a boolean argument.

For golang/go#30940.

Change-Id: I00ad51ec55abfb2de28deb8c98f949989ece1099
Reviewed-on: https://go-review.googlesource.com/c/text/+/317729
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
diff --git a/internal/export/idna/conformance_test.go b/internal/export/idna/conformance_test.go
index 1cdf43c..3e0e875 100644
--- a/internal/export/idna/conformance_test.go
+++ b/internal/export/idna/conformance_test.go
@@ -2,6 +2,9 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+//go:build go1.10
+// +build go1.10
+
 package idna
 
 import (
diff --git a/internal/export/idna/idna10.0.0.go b/internal/export/idna/idna10.0.0.go
index 3e7bac3..e6b62a2 100644
--- a/internal/export/idna/idna10.0.0.go
+++ b/internal/export/idna/idna10.0.0.go
@@ -59,10 +59,10 @@
 // Transitional sets a Profile to use the Transitional mapping as defined in UTS
 // #46. This will cause, for example, "ß" to be mapped to "ss". Using the
 // transitional mapping provides a compromise between IDNA2003 and IDNA2008
-// compatibility. It is used by most browsers when resolving domain names. This
+// compatibility. It is used by some browsers when resolving domain names. This
 // option is only meaningful if combined with MapForLookup.
 func Transitional(transitional bool) Option {
-	return func(o *options) { o.transitional = true }
+	return func(o *options) { o.transitional = transitional }
 }
 
 // VerifyDNSLength sets whether a Profile should fail if any of the IDN parts
diff --git a/internal/export/idna/idna10.0.0_test.go b/internal/export/idna/idna10.0.0_test.go
index 4142bfa..0b9f7a8 100644
--- a/internal/export/idna/idna10.0.0_test.go
+++ b/internal/export/idna/idna10.0.0_test.go
@@ -34,6 +34,10 @@
 	std3 := kind{"STD3", p.ToASCII}
 	p = New(MapForLookup(), CheckHyphens(false))
 	hyphens := kind{"CheckHyphens", p.ToASCII}
+	p = New(MapForLookup(), Transitional(true))
+	transitional := kind{"Transitional", p.ToASCII}
+	p = New(MapForLookup(), Transitional(false))
+	nontransitional := kind{"Nontransitional", p.ToASCII}
 
 	testCases := []struct {
 		kind
@@ -95,14 +99,16 @@
 		{hyphens, "-label-.com", "-label-.com", ""},
 
 		// Don't map U+2490 (DIGIT NINE FULL STOP). This is the behavior of
-		// Chrome, Safari, and IE. Firefox will first map ⒐ to 9. and return
-		// lab9.be.
+		// Chrome, modern Firefox, Safari, and IE.
 		{resolve, "lab⒐be", "xn--labbe-zh9b", "P1"}, // encode("lab⒐be")
 		{display, "lab⒐be", "lab⒐be", "P1"},
-
 		{resolve, "plan⒐faß.de", "xn--planfass-c31e.de", "P1"}, // encode("plan⒐fass") + ".de"
 		{display, "Plan⒐faß.de", "plan⒐faß.de", "P1"},
 
+		// Transitional vs Nontransitional processing
+		{transitional, "Plan9faß.de", "plan9fass.de", ""},
+		{nontransitional, "Plan9faß.de", "xn--plan9fa-6va.de", ""},
+
 		// Chrome 54.0 recognizes the error and treats this input verbatim as a
 		// search string.
 		// Safari 10.0 (non-conform spec) decomposes "⒈" and computes the
diff --git a/internal/export/idna/idna9.0.0.go b/internal/export/idna/idna9.0.0.go
index 7acecb8..4979fdc 100644
--- a/internal/export/idna/idna9.0.0.go
+++ b/internal/export/idna/idna9.0.0.go
@@ -58,10 +58,10 @@
 // Transitional sets a Profile to use the Transitional mapping as defined in UTS
 // #46. This will cause, for example, "ß" to be mapped to "ss". Using the
 // transitional mapping provides a compromise between IDNA2003 and IDNA2008
-// compatibility. It is used by most browsers when resolving domain names. This
+// compatibility. It is used by some browsers when resolving domain names. This
 // option is only meaningful if combined with MapForLookup.
 func Transitional(transitional bool) Option {
-	return func(o *options) { o.transitional = true }
+	return func(o *options) { o.transitional = transitional }
 }
 
 // VerifyDNSLength sets whether a Profile should fail if any of the IDN parts
diff --git a/internal/export/idna/idna9.0.0_test.go b/internal/export/idna/idna9.0.0_test.go
index b76b796..524727b 100644
--- a/internal/export/idna/idna9.0.0_test.go
+++ b/internal/export/idna/idna9.0.0_test.go
@@ -34,6 +34,10 @@
 	std3 := kind{"STD3", p.ToASCII}
 	p = New(MapForLookup(), CheckHyphens(false))
 	hyphens := kind{"CheckHyphens", p.ToASCII}
+	p = New(MapForLookup(), Transitional(true))
+	transitional := kind{"Transitional", p.ToASCII}
+	p = New(MapForLookup(), Transitional(false))
+	nontransitional := kind{"Nontransitional", p.ToASCII}
 
 	testCases := []struct {
 		kind
@@ -91,14 +95,16 @@
 		{hyphens, "-label-.com", "-label-.com", ""},
 
 		// Don't map U+2490 (DIGIT NINE FULL STOP). This is the behavior of
-		// Chrome, Safari, and IE. Firefox will first map ⒐ to 9. and return
-		// lab9.be.
+		// Chrome, modern Firefox, Safari, and IE.
 		{resolve, "lab⒐be", "xn--labbe-zh9b", "P1"}, // encode("lab⒐be")
 		{display, "lab⒐be", "lab⒐be", "P1"},
-
 		{resolve, "plan⒐faß.de", "xn--planfass-c31e.de", "P1"}, // encode("plan⒐fass") + ".de"
 		{display, "Plan⒐faß.de", "plan⒐faß.de", "P1"},
 
+		// Transitional vs Nontransitional processing
+		{transitional, "Plan9faß.de", "plan9fass.de", ""},
+		{nontransitional, "Plan9faß.de", "xn--plan9fa-6va.de", ""},
+
 		// Chrome 54.0 recognizes the error and treats this input verbatim as a
 		// search string.
 		// Safari 10.0 (non-conform spec) decomposes "⒈" and computes the